mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-21 21:44:01 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d53e2fe19a | |||
| fcf3d24ae4 |
@@ -39,11 +39,6 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
$query = $query->orderBy($filters->get('order_by')->column, $filters->get('order_by')->DESC ? 'DESC': 'ASC');
|
$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();
|
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<?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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class DoesNotHaveTransactionType implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
|
||||||
$query->where('type', $value);
|
|
||||||
})->whereHas('containers', function ($query){
|
|
||||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class HasInvoiceStatusIn 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('type', 1)->whereIn('status', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class HasTransactionType 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('type', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?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');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?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));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class SegmentIdIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereIn('segment_id', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?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);
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<?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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Announcements\Services;
|
|||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||||
use App\Models\Announcement;
|
use App\Models\Announcement;
|
||||||
use DateTime;
|
|
||||||
|
|
||||||
class CreatesAnnouncement extends AbstractUpdateRecord
|
class CreatesAnnouncement extends AbstractUpdateRecord
|
||||||
{
|
{
|
||||||
@@ -19,17 +18,9 @@ class CreatesAnnouncement extends AbstractUpdateRecord
|
|||||||
$model = new Announcement();
|
$model = new Announcement();
|
||||||
$model->title = $object->getTitle();
|
$model->title = $object->getTitle();
|
||||||
$model->description = $object->getDescription();
|
$model->description = $object->getDescription();
|
||||||
// $model->starting_on = $object->getStartingOn();
|
$model->starting_on = $object->getStartingOn();
|
||||||
$model->starting_on = $this->convertDateFormat($object->getStartingOn());
|
$model->ending_on = $object->getEndingOn();
|
||||||
// $model->ending_on = $object->getEndingOn();
|
|
||||||
$model->ending_on = $this->convertDateFormat($object->getEndingOn());
|
|
||||||
|
|
||||||
return $this->handler($model);
|
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,8 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
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\DataTransferObjects\WalletObject;
|
||||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||||
|
|
||||||
@@ -23,7 +21,6 @@ use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
|||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@@ -38,27 +35,21 @@ class CallbackBillplzLogic
|
|||||||
/** @var UpdatesTransactionStatus */
|
/** @var UpdatesTransactionStatus */
|
||||||
private $updatesTransactionStatus;
|
private $updatesTransactionStatus;
|
||||||
|
|
||||||
/** @var UpdateDoFromVTPortalProcessor */
|
/** @var UpdatesWalletBalance */
|
||||||
private $updateDoFromVTPortalProcessor;
|
private $updatesWalletBalance;
|
||||||
|
|
||||||
/** @var UpdateDoFromYDPortalProcessor */
|
|
||||||
private $updateDoFromYDPortalProcessor ;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CallbackBillplzLogic constructor.
|
* CallbackBillplzLogic constructor.
|
||||||
* @param GetBillplzBill $getBillplzBill
|
* @param GetBillplzBill $getBillplzBill
|
||||||
* @param FetchesTransaction $fetchesTransaction
|
* @param FetchesTransaction $fetchesTransaction
|
||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
|
||||||
*/
|
*/
|
||||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||||
{
|
{
|
||||||
$this->getBillplzBill = $getBillplzBill;
|
$this->getBillplzBill = $getBillplzBill;
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
$this->fetchesTransaction = $fetchesTransaction;
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
|
||||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -67,8 +58,6 @@ class CallbackBillplzLogic
|
|||||||
* @return bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
* @return bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
* @throws MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
* @throws \App\Classes\Exceptions\InternalServerErrorException
|
|
||||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
||||||
*/
|
*/
|
||||||
public function execute(Request $request)
|
public function execute(Request $request)
|
||||||
{
|
{
|
||||||
@@ -84,12 +73,6 @@ class CallbackBillplzLogic
|
|||||||
|
|
||||||
$transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
|
$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') {
|
if($billPlz->state === 'paid') {
|
||||||
$status = ApprovalStatus::APPROVED;
|
$status = ApprovalStatus::APPROVED;
|
||||||
}
|
}
|
||||||
@@ -101,23 +84,8 @@ class CallbackBillplzLogic
|
|||||||
$token = Auth::fromUser(User::find(1));
|
$token = Auth::fromUser(User::find(1));
|
||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||||
|
|
||||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
|
$marking = $transaction->owner()->first()->owner()->first();
|
||||||
|
|
||||||
if(($invoice->amount - $transaction->amount) < 0.01) {
|
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $marking->reference, 'transaction' => $transaction, 'status' => $status]);
|
||||||
$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{
|
try{
|
||||||
// config('billplz.maybank')
|
// config('billplz.maybank')
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||||
'collection_id' => config('billplz.collection_id'),
|
'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'),
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
|
|||||||
+9
-9
@@ -97,15 +97,15 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->updatesCompanyStatus->execute($document->owner, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
$this->updatesCompanyStatus->execute($document->owner, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||||
|
|
||||||
// $object = new NotificationObject(
|
$object = new NotificationObject(
|
||||||
// 'ID Verification ' . ( $status === 'approve' ? 'Approved' : 'Rejected' ),
|
'ID Verification ' . ( $status === 'approve' ? 'Approved' : 'Rejected' ),
|
||||||
// ( $status === 'approve' ? 'Dear user, congratulations that your ' : 'Dear user, we are sorry to inform you that your ' ) . ( $document->type === 'IDENTITY_CARD' ? 'IC' : 'SSM' ) . ( $status === 'approve' ? ' has been approved. Start your first order now!' : ' has been rejected due to ' . ( $request->input('rejectRemark') ?? '' ) . ', please resubmit it for further action.' ),
|
( $status === 'approve' ? 'Dear user, congratulations that your ' : 'Dear user, we are sorry to inform you that your ' ) . ( $document->type === 'IDENTITY_CARD' ? 'IC' : 'SSM' ) . ( $status === 'approve' ? ' has been approved. Start your first order now!' : ' has been rejected due to ' . ( $request->input('rejectRemark') ?? '' ) . ', please resubmit it for further action.' ),
|
||||||
// $document->owner,
|
$document->owner,
|
||||||
// $document->owner->companyModules()->first()->employees()->first(),
|
$document->owner->companyModules()->first()->employees()->first(),
|
||||||
// $document,
|
$document,
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $this->createNotificationProcessor->execute($object);
|
$this->createNotificationProcessor->execute($object);
|
||||||
|
|
||||||
if($status === 'approve'){
|
if($status === 'approve'){
|
||||||
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\Companies\Services;
|
|||||||
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Segment;
|
use App\Models\Segment;
|
||||||
use Illuminate\Database\QueryException;
|
use Illuminate\Database\QueryException;
|
||||||
@@ -20,9 +19,8 @@ class AssignsCompanyToSegment extends AbstractUpdateRecord
|
|||||||
public function execute(Company $company, Segment $segment)
|
public function execute(Company $company, Segment $segment)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$companyModule = $company->companyModules()->where('type', BusinessType::IMPORTER)->first();
|
|
||||||
$connection = $companyModule->connections()->where('inviter_reference', 'CIEF');
|
$company->segments()->attach($segment);
|
||||||
$connection->segments()->attach($segment);
|
|
||||||
|
|
||||||
return $company;
|
return $company;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class FileObject implements DataTransferObject
|
|||||||
*/
|
*/
|
||||||
public function getData()
|
public function getData()
|
||||||
{
|
{
|
||||||
return in_array($this->getExtension(), ['pdf', 'excel']) ? $this->data : (new imageManager())->make($this->data);
|
return $this->getExtension() === 'pdf' ? $this->data : (new imageManager())->make($this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +66,7 @@ class FileObject implements DataTransferObject
|
|||||||
*/
|
*/
|
||||||
public function getDecodedData(): string
|
public function getDecodedData(): string
|
||||||
{
|
{
|
||||||
return in_array($this->getExtension(), ['pdf', 'excel']) ?
|
return $this->getExtension() === 'pdf' ?
|
||||||
base64_decode((explode('base64,', $this->getData()))[1]):
|
base64_decode((explode('base64,', $this->getData()))[1]):
|
||||||
$this->getData()->encode('data-url')->encoded;
|
$this->getData()->encode('data-url')->encoded;
|
||||||
}
|
}
|
||||||
@@ -78,4 +78,9 @@ class FileObject implements DataTransferObject
|
|||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ class ConvertsBase64ToFile
|
|||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
|
||||||
$object = new FileObject($file);
|
$object = new FileObject($file);
|
||||||
in_array($object->getExtension(), ['pdf', 'excel']) ? $this->generatePDF($object) : $this->generateImage($object);
|
$object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\Exports\Services;
|
|||||||
|
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
<?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
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
<?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
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
''
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Classes\Modules\Exports\Services;
|
namespace App\Classes\Modules\Exports\Services;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||||
@@ -47,12 +46,11 @@ class ExportsOnHoldPackingList implements FromQuery, WithHeadings, WithHeadingRo
|
|||||||
$container = $packingList->containers()->first();
|
$container = $packingList->containers()->first();
|
||||||
$ContainerTransport = $container->transports()->first();
|
$ContainerTransport = $container->transports()->first();
|
||||||
$order = $packingList->owner;
|
$order = $packingList->owner;
|
||||||
if(!$order instanceof Order)return [];
|
|
||||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$container->reference,
|
$container->reference,
|
||||||
$ContainerTransport ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first() ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta : 'n/a' : 'n/a',
|
$ContainerTransport ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta : 'n/a',
|
||||||
$ContainerTransport ? $ContainerTransport->drop_date : 'n/a',
|
$ContainerTransport ? $ContainerTransport->drop_date : 'n/a',
|
||||||
$marking,
|
$marking,
|
||||||
$order->reference,
|
$order->reference,
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?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
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
<?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()
|
public function query()
|
||||||
{
|
{
|
||||||
return PackingList::where('type', '=', 2)->whereHas('containers', function ($query){
|
return PackingList::where('type', '=', 2)->whereHas('containers', function ($query){
|
||||||
$query->where('containers.status', ApprovalStatus::COMPLETED)->where('containers.created_at', '>', Carbon::now()->subMonths(3));
|
$query->where('containers.status', ApprovalStatus::COMPLETED);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,23 +57,21 @@ class ExportsPendingArrangementDeliveryList implements FromQuery, WithHeadings,
|
|||||||
$container = $packingList->containers()->first();
|
$container = $packingList->containers()->first();
|
||||||
$ContainerTransport = $container->transports()->first();
|
$ContainerTransport = $container->transports()->first();
|
||||||
$order = $packingList->owner;
|
$order = $packingList->owner;
|
||||||
$inviter = $order->companyModule ? $order->companyModule->inviters()->withPivot('invitee_reference')->first() : null;
|
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||||
$marking = $inviter ? $inviter->pivot->invitee_reference : 'Unclaimed';
|
|
||||||
$address = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
$address = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||||
$contacts = $address->contacts->first() ? $address->contacts->first(): '';
|
$contacts = $address->contacts->first() ? $address->contacts->first(): '';
|
||||||
$originalPackingList = $packingList->owner instanceof PackingList ? $packingList->owner : $packingList;
|
$originalPackingList = $packingList->owner instanceof PackingList ? $packingList->owner : $packingList;
|
||||||
$transport = $originalPackingList->containers()->first()->transports()->first();
|
$transport = $originalPackingList->containers()->first()->transports()->first();
|
||||||
$deliveryTransport = $originalPackingList->transports()->first();
|
$deliveryTransport = $originalPackingList->transports()->first();
|
||||||
$schedule = $deliveryTransport ? $deliveryTransport->schedules()->first() : null;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$container->reference,
|
$container->reference,
|
||||||
$ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first() ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta : '',
|
$ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta,
|
||||||
$ContainerTransport->drop_date,
|
$ContainerTransport->drop_date,
|
||||||
$marking,
|
$marking,
|
||||||
$order->reference,
|
$order->reference,
|
||||||
$schedule ? (Carbon::parse($schedule->eta) < Carbon::now() ? 'Delivered' : 'Pending Delivery') : 'Pending Arrangement',
|
$deliveryTransport ? (Carbon::parse($deliveryTransport->schedules()->first()->eta) < Carbon::now() ? 'Delivered' : 'Pending Delivery') : 'Pending Arrangement',
|
||||||
$schedule ? $schedule->eta : ($transport ? Carbon::now()->diffInDays($transport->drop_date, false) . ' Days' : ''),
|
$deliveryTransport ? $deliveryTransport->schedules()->first()->eta : ($transport ? Carbon::now()->diffInDays($transport->drop_date, false) . ' Days' : ''),
|
||||||
$packingList->packages()->sum('quantity'),
|
$packingList->packages()->sum('quantity'),
|
||||||
$address->state->name,
|
$address->state->name,
|
||||||
$address->postcode,
|
$address->postcode,
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
<?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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
<?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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<?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,7 +3,6 @@
|
|||||||
namespace App\Classes\Modules\Orders\Processors;
|
namespace App\Classes\Modules\Orders\Processors;
|
||||||
|
|
||||||
use App\Classes\Exceptions\InternalServerErrorException;
|
use App\Classes\Exceptions\InternalServerErrorException;
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||||
|
|
||||||
@@ -55,7 +54,6 @@ class UpdateDoFromYDPortalProcessor
|
|||||||
$reference = $contact ? $contact->reference : null;
|
$reference = $contact ? $contact->reference : null;
|
||||||
$remark = $remark ? $remark->content : 'URGENT!!! PLEASE CALL BEFORE ONE DAY DELIVERY.';
|
$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(
|
$this->fetchesDataFRomYDPortal->clientRequest(
|
||||||
'http://www.yd-wl.com/api/UpdateOrderAddress.ashx',
|
'http://www.yd-wl.com/api/UpdateOrderAddress.ashx',
|
||||||
'POST',
|
'POST',
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||||
|
|
||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||||
@@ -135,25 +134,20 @@ class AssignPackingListOrderLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||||
|
|
||||||
try {
|
$packing_list = $this->fetchesPackingList->execute([
|
||||||
$packing_list = $this->fetchesPackingList->execute([
|
'reference' => $warehouse_packing_list->reference,
|
||||||
'reference' => $warehouse_packing_list->reference,
|
'type' => PackingListType::SHIPPING_PACKING_LIST
|
||||||
'type' => PackingListType::SHIPPING_PACKING_LIST
|
]);
|
||||||
]);
|
|
||||||
|
|
||||||
$warehouse_packing_list = $this->updatesPackingListOwner->execute($packing_list, $order);
|
$warehouse_packing_list = $this->updatesPackingListOwner->execute($packing_list, $order);
|
||||||
|
|
||||||
$this->updatesPackingListContractReference->execute($packing_list, $contractReference);
|
$this->updatesPackingListContractReference->execute($packing_list, $contractReference);
|
||||||
|
|
||||||
foreach($contractObligations as $obligation) {
|
|
||||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
|
||||||
$this->createsStep->execute($packing_list, $stepObject);
|
|
||||||
}
|
|
||||||
} catch (ResourceNotFoundException $exception) {
|
|
||||||
|
|
||||||
|
foreach($contractObligations as $obligation) {
|
||||||
|
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||||
|
$this->createsStep->execute($packing_list, $stepObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new PackingListResource($warehouse_packing_list));
|
return $this->resourceResponse(new PackingListResource($warehouse_packing_list));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\PackingLists\Services\DeletesPackingList;
|
use App\Classes\Modules\PackingLists\Services\DeletesPackingList;
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList;
|
use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -60,9 +58,9 @@ class DeletePackingListLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->canDeletePackingList->passes();
|
$this->canDeletePackingList->passes();
|
||||||
|
|
||||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
$query = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
PackingList::where('reference', $packingList->reference)->delete();
|
$this->deletesPackingList->execute($query);
|
||||||
|
|
||||||
return $this->response([]);
|
return $this->response([]);
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,9 @@ use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
|||||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||||
use App\Classes\Modules\Schedules\Services\UpdatesScheduleStatus;
|
use App\Classes\Modules\Schedules\Services\UpdatesScheduleStatus;
|
||||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
|
||||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\TransportType;
|
|
||||||
use App\Http\Resources\PackingListResource;
|
use App\Http\Resources\PackingListResource;
|
||||||
use App\Models\Transport;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -21,8 +17,6 @@ use Carbon\Carbon;
|
|||||||
|
|
||||||
class ReschedulePackingListLogic extends AbstractControllerLogic
|
class ReschedulePackingListLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -39,31 +33,26 @@ class ReschedulePackingListLogic extends AbstractControllerLogic
|
|||||||
/** @var UpdatesScheduleStatus */
|
/** @var UpdatesScheduleStatus */
|
||||||
private $updatesScheduleStatus;
|
private $updatesScheduleStatus;
|
||||||
|
|
||||||
/** @var CreatesTransport */
|
|
||||||
private $createsTransport;
|
|
||||||
|
|
||||||
/** @var CreatesSchedule */
|
/** @var CreatesSchedule */
|
||||||
private $createsSchedule;
|
private $createsSchedule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReschedulePackingListLogic constructor.
|
* DeleteContainerControllersLogic constructor.
|
||||||
* @param FetchesPackingList $fetchesPackingList
|
* @param FetchesPackingList $fetchesPackingList
|
||||||
* @param UpdatesScheduleStatus $updatesScheduleStatus
|
|
||||||
* @param CreatesTransport $createsTransport
|
|
||||||
* @param CreatesSchedule $createsSchedule
|
* @param CreatesSchedule $createsSchedule
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesScheduleStatus $updatesScheduleStatus, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
|
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesScheduleStatus $updatesScheduleStatus, CreatesSchedule $createsSchedule)
|
||||||
{
|
{
|
||||||
$this->fetchesPackingList = $fetchesPackingList;
|
$this->fetchesPackingList = $fetchesPackingList;
|
||||||
$this->updatesScheduleStatus = $updatesScheduleStatus;
|
$this->updatesScheduleStatus = $updatesScheduleStatus;
|
||||||
$this->createsTransport = $createsTransport;
|
|
||||||
$this->createsSchedule = $createsSchedule;
|
$this->createsSchedule = $createsSchedule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws ErrorException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
@@ -71,15 +60,9 @@ class ReschedulePackingListLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$transport = $packing_list->transports()->first();
|
$transport = $packing_list->transports()->first();
|
||||||
|
|
||||||
if(!$transport) {
|
$old_sechedule = $transport->schedules()->first();
|
||||||
$object = new TransportObject(TransportType::LAND, null, '', Carbon::parse($request->input('etd')), Carbon::parse($request->input('eta')),ApprovalStatus::APPROVED);
|
|
||||||
/** @var Transport $transport */
|
|
||||||
$transport = $this->createsTransport->execute($object, $packing_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
$transport->schedules()->update([
|
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||||
'status' => ApprovalStatus::REJECTED
|
|
||||||
]);
|
|
||||||
|
|
||||||
$scheduleObject = new ScheduleObject(
|
$scheduleObject = new ScheduleObject(
|
||||||
Carbon::parse($request->input('eta')),
|
Carbon::parse($request->input('eta')),
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ class FetchDeliveryListFromVTPortalProcessor
|
|||||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||||
|
|
||||||
} catch (GuzzleException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
|
dd($exception);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+43
-128
@@ -7,15 +7,12 @@ use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
|||||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
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\DataTransferObjects\PackingListObject;
|
||||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
|
||||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
|
||||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||||
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
||||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
||||||
@@ -24,13 +21,10 @@ use App\Classes\Modules\Unity\Services\CreatesContract;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
use App\Classes\ValueObjects\Constants\PackageType;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
use App\Classes\ValueObjects\Constants\TransportType;
|
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use App\Models\Transport;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -130,8 +124,9 @@ class FetchLoadedContainersFromVTPortalProcessor
|
|||||||
*/
|
*/
|
||||||
public function execute(?Carbon $start = null, ?Carbon $end = null){
|
public function execute(?Carbon $start = null, ?Carbon $end = null){
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
try {
|
try {
|
||||||
$start = $start ? $start : Carbon::today()->subDays(5);
|
$start = $start ? $start : Carbon::now()->subDays(10);
|
||||||
|
|
||||||
$startLimit = Carbon::parse('11-08-2021');
|
$startLimit = Carbon::parse('11-08-2021');
|
||||||
|
|
||||||
@@ -139,162 +134,80 @@ class FetchLoadedContainersFromVTPortalProcessor
|
|||||||
$start = $startLimit;
|
$start = $startLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$end = $end ? $end : Carbon::today()->addDay();
|
$end = $end ? $end : Carbon::now();
|
||||||
$filter = '["LoadedTime:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]';
|
$filter = '["LoadedTime:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]';
|
||||||
|
|
||||||
$containersRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"LoadedTime asc","Filter":'.$filter.'}}'), '');
|
$containersRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"LoadedTime asc","Filter":'.$filter.'}}'), '');
|
||||||
|
|
||||||
$containers = $this->fetchesDataFRomVTPortal->getResponseBody($containersRequest);
|
$containers = $this->fetchesDataFRomVTPortal->getResponseBody($containersRequest);
|
||||||
|
|
||||||
foreach ($containers->Rows as $container){
|
foreach ($containers->Rows as $container){
|
||||||
$filter = '["ContainerID:=%js%'.$container[12].'"]';
|
$filter = '["ContainerID:=%js%'.$container[11].'"]';
|
||||||
$containerDetailRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"ParcelInContainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":null,"Filter":'.$filter.'}}'), '');
|
$containerDetailRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||||
|
|
||||||
$containerDetail = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailRequest);
|
$containerDetail = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailRequest);
|
||||||
|
|
||||||
$containerObject = new ContainerObject($container[0], str_replace(' ', '', $container[24]), str_replace(' ', '', $container[16]), ContainerTypes::FORTY_FEET_DRY_CONTAINER, Carbon::parse($container[6]), ApprovalStatus::PENDING_VERIFICATION);
|
$containerObject = new ContainerObject($container[0], str_replace(' ', '', $container[24]), str_replace(' ', '', $container[15]), ContainerTypes::FORTY_FEET_DRY_CONTAINER, Carbon::parse($container[5]), ApprovalStatus::PENDING_VERIFICATION);
|
||||||
$containerInfo = $container;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$container = $this->fetchesContainer->execute(['reference' => $containerObject->getReference()]);
|
$container = $this->fetchesContainer->execute(['reference' => $containerObject->getReference()]);
|
||||||
} catch (ResourceNotFoundException $exception){
|
} catch (ResourceNotFoundException $exception){
|
||||||
$warehouseId = $container[13];
|
$warehouseId = $container[12];
|
||||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]);
|
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]);
|
||||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
$eta = Carbon::parse($containerInfo[4])->addDays(2);
|
|
||||||
$etd = Carbon::parse($eta)->subDays(7);
|
|
||||||
|
|
||||||
$delayDate = $containerInfo[7];
|
|
||||||
|
|
||||||
$containerStatus = $containerInfo[10];
|
|
||||||
|
|
||||||
$unstuffingDate = $containerInfo[8];
|
|
||||||
|
|
||||||
$transport = $container->transports()->first();
|
|
||||||
|
|
||||||
if(!$transport || $eta !== $transport->eta){
|
|
||||||
$container->transports()->delete();
|
|
||||||
|
|
||||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED);
|
|
||||||
/** @var Transport $transport */
|
|
||||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED));
|
|
||||||
}
|
|
||||||
|
|
||||||
if($delayDate){
|
|
||||||
$delayDate = Carbon::parse($delayDate)->addDays(2);
|
|
||||||
$transport = $container->transports()->first();
|
|
||||||
|
|
||||||
if(!$transport->schedules()->where('eta', '=', $delayDate)->first()) {
|
|
||||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
|
||||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if($containerStatus === 'Unstuffing'){
|
|
||||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
$container->transports()->first()->update(['drop_date' => Carbon::parse($unstuffingDate)->subDay(), 'status' => ApprovalStatus::COMPLETED]);
|
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
|
||||||
foreach($container->packingLists as $packingList){
|
|
||||||
|
|
||||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
|
||||||
$packingList->status = ApprovalStatus::APPROVED;
|
|
||||||
$packingList->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($containerDetail->Rows as $packingList){
|
foreach($containerDetail->Rows as $packingList){
|
||||||
$marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $packingList[39]));
|
$marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $packingList[13]));
|
||||||
|
|
||||||
$orderNumber = $marking[array_key_last($marking)];
|
$orderNumber = $marking[array_key_last($marking)];
|
||||||
|
|
||||||
if(!$packingList[11]){
|
if(!$packingList[22]){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allow_contract = true;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$warehousePackingList = $this->fetchesPackingList->execute(['reference' => $packingList[3]]);
|
/** @var Order $order */
|
||||||
if(!$warehousePackingList->owner instanceof Order) throw new ResourceNotFoundException;
|
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||||
$order = $warehousePackingList->owner;
|
} catch (ResourceNotFoundException $exception){
|
||||||
} catch (ResourceNotFoundException $exception) {
|
continue;
|
||||||
try {
|
|
||||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
|
||||||
} catch (ResourceNotFoundException $exception) {
|
|
||||||
try {
|
|
||||||
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
|
||||||
} catch (ResourceNotFoundException $exception) {
|
|
||||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
|
||||||
$allow_contract = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$packingListReference = $packingList[16];
|
||||||
|
|
||||||
$packingListReference = $packingList[3];
|
try{
|
||||||
$package = $packingList;
|
$this->fetchesPackingList->execute(['reference' => $packingListReference]);
|
||||||
$deliveryDate = $package[1] ? Carbon::parse($package[1]) : null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$packingList = $this->fetchesPackingList->execute(['reference' => $packingListReference, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
|
||||||
} catch (ResourceNotFoundException $exception){
|
} catch (ResourceNotFoundException $exception){
|
||||||
if ($allow_contract) {
|
$contract = $this->unityCreateContract->execute();
|
||||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
$contractReference = $contract->hash_id;
|
||||||
// $contract = $this->unityCreateContract->execute();
|
$contractObligations = $contract->contract_obligation_list;
|
||||||
// $contractReference = $contract->hash_id;
|
|
||||||
// $contractObligations = $contract->contract_obligation_list;
|
|
||||||
//
|
|
||||||
// $this->unityActivateContract->execute($contractReference);
|
|
||||||
//
|
|
||||||
// $supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
|
||||||
//
|
|
||||||
// $supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
|
||||||
// $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
|
||||||
//
|
|
||||||
// $importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
|
||||||
// $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
|
||||||
//
|
|
||||||
// $this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
|
||||||
} else {
|
|
||||||
$appointee_id = 2037;
|
|
||||||
}
|
|
||||||
|
|
||||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, null);
|
$this->unityActivateContract->execute($contractReference);
|
||||||
|
|
||||||
|
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
||||||
|
|
||||||
|
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
||||||
|
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
||||||
|
|
||||||
|
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
||||||
|
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
||||||
|
|
||||||
|
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||||
|
|
||||||
|
$connection = $order->companyModule->connections()->first();
|
||||||
|
$marking = $connection->invitee_reference;
|
||||||
|
|
||||||
|
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, $contractReference);
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
/** @var PackingList $packingList */
|
||||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||||
}
|
$container->packingLists()->attach($packingList);
|
||||||
|
|
||||||
$container->packingLists()->detach($packingList);
|
foreach($contractObligations as $obligation) {
|
||||||
$container->packingLists()->attach($packingList);
|
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||||
$packingList->packages()->delete();
|
$this->createsStep->execute($packingList, $stepObject);
|
||||||
|
|
||||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
|
||||||
if($replica) $replica->packages()->delete();
|
|
||||||
|
|
||||||
$packageObject = new PackageObject(PackageType::CARTON, $package[8], $package[21], $package[22], $package[20], 0, $package[11], ApprovalStatus::APPROVED);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
|
||||||
if($containerStatus === 'Unstuffing'){
|
|
||||||
$packingList->transports()->delete();
|
|
||||||
|
|
||||||
if($deliveryDate) {
|
|
||||||
// && !$packingList->transports()->exists()
|
|
||||||
$packingList->status = ApprovalStatus::COMPLETED;
|
|
||||||
$packingList->save();
|
|
||||||
|
|
||||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
|
||||||
/** @var Transport $transport */
|
|
||||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -304,6 +217,8 @@ class FetchLoadedContainersFromVTPortalProcessor
|
|||||||
Log::error($exception);
|
Log::error($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-57
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Classes\Modules\PackingLists\Processors;
|
namespace App\Classes\Modules\PackingLists\Processors;
|
||||||
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||||
@@ -24,8 +23,6 @@ use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
|||||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
||||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
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\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
@@ -135,12 +132,11 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
* @param Carbon|null $start
|
* @param Carbon|null $start
|
||||||
* @param Carbon|null $end
|
* @param Carbon|null $end
|
||||||
* @return void
|
* @return void
|
||||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
||||||
*/
|
*/
|
||||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$start = $start ? $start : Carbon::today()->subDays(30);
|
$start = $start ? $start : Carbon::now()->subMonths(2);
|
||||||
|
|
||||||
$startLimit = Carbon::parse('01-12-2021');
|
$startLimit = Carbon::parse('01-12-2021');
|
||||||
|
|
||||||
@@ -148,7 +144,7 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$start = $startLimit;
|
$start = $startLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$end = $end ? $end : Carbon::today()->addDay();
|
$end = $end ? $end : Carbon::now();
|
||||||
|
|
||||||
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
||||||
'begintime' => $start->timestamp,
|
'begintime' => $start->timestamp,
|
||||||
@@ -158,7 +154,6 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||||
|
|
||||||
foreach($rows->data as $row){
|
foreach($rows->data as $row){
|
||||||
|
|
||||||
$containerReference = null;
|
$containerReference = null;
|
||||||
$loadingDate = null;
|
$loadingDate = null;
|
||||||
$unstuffingDate = null;
|
$unstuffingDate = null;
|
||||||
@@ -174,6 +169,7 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||||
|
|
||||||
if(!$rows){
|
if(!$rows){
|
||||||
|
Log::debug($row->expressno);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +183,7 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
||||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
$etd = Carbon::parse($tracking[2])->subDays(5);
|
||||||
$eta = Carbon::parse($tracking[2])->addDays(2);
|
$eta = Carbon::parse($tracking[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
||||||
@@ -206,7 +202,6 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rescheduleDate = $dates->sortDesc()->first();
|
$rescheduleDate = $dates->sortDesc()->first();
|
||||||
|
|
||||||
if(!$delayDate || $rescheduleDate > $delayDate){
|
if(!$delayDate || $rescheduleDate > $delayDate){
|
||||||
/** @var Carbon $delayDate */
|
/** @var Carbon $delayDate */
|
||||||
$delayDate = $rescheduleDate;
|
$delayDate = $rescheduleDate;
|
||||||
@@ -218,42 +213,20 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($trackingRow->tracking === '到港') {
|
|
||||||
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '已开船') {
|
if ($trackingRow->tracking === '已开船') {
|
||||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Str::contains($trackingRow->tracking, ['派送中', '已签收', '签收完成', ' 第三方提货', '货物已派送完成', '派送', 'delivery', 'delivered'])) {
|
if (Str::contains($trackingRow->tracking, ['派送中'])) {
|
||||||
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$row->expressno.'&sOrgId=sti');
|
|
||||||
$deliveryTracking = json_decode($request->getBody()->getContents());
|
|
||||||
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
|
||||||
$trackingDate = Carbon::createFromFormat('d/m/y H:i', $trackingRow->LocalDateTime);
|
|
||||||
if (Str::contains($trackingRow->PublicDescription, ['accepted/picked'])){
|
|
||||||
$unstuffingDate = $trackingDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
|
||||||
$deliveryDate = $trackingDate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Exception $exception){
|
|
||||||
Log::debug('failed to fetch delivery tracking');
|
|
||||||
}
|
|
||||||
|
|
||||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||||
|
|
||||||
$orderNumber = $customerno[array_key_last($customerno)];
|
$orderNumber = $customerno[array_key_last($customerno)];
|
||||||
@@ -271,6 +244,8 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
$packingListReference = $row->expressno;
|
$packingListReference = $row->expressno;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -358,7 +333,7 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
|
|
||||||
if($order instanceof Order){
|
if($order instanceof Order){
|
||||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||||
if(!in_array($marking, ['1290CSW', '8997ITB', '3992WHE', '962LOW', '1152AAT'])){
|
if(!in_array($marking, ['2192KAA', '2353GFE', '6866DTR', '153DSR', '1291NSC', '8288MIB'])){
|
||||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
||||||
'expressno' => $row->expressno
|
'expressno' => $row->expressno
|
||||||
]);
|
]);
|
||||||
@@ -400,20 +375,13 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($delayDate){
|
if($delayDate){
|
||||||
$delayDate = $delayDate->addDays(2);
|
|
||||||
$transport = $container->transports()->first();
|
$transport = $container->transports()->first();
|
||||||
|
|
||||||
if(!$transport->schedules()->whereDate('eta', '>=', $delayDate)->first()) {
|
if(!$transport->schedules()->whereDate('eta', '>=', $delayDate)->first()) {
|
||||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
||||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
$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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -430,14 +398,11 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$packingList->save();
|
$packingList->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($allow_contract) {
|
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
||||||
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
||||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
||||||
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -452,16 +417,13 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||||
|
|
||||||
|
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
||||||
if ($allow_contract) {
|
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
|
||||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
echo 'successful';
|
echo 'successful';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-9
@@ -46,32 +46,42 @@ class FetchPackingListFromVTPortalProcessor
|
|||||||
*/
|
*/
|
||||||
public function execute(){
|
public function execute(){
|
||||||
|
|
||||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->where('reference', 'not like', '%PO%')->whereIn('claimant_id', [2])->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->whereDoesntHave('containers', function($query){
|
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->whereDoesntHave('containers', function($query){
|
||||||
$query->where('status', '=', ApprovalStatus::COMPLETED);
|
$query->where('status', '=', ApprovalStatus::COMPLETED);
|
||||||
})->limit(10)->get();
|
})->get();
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
foreach($packingLists as $packingList){
|
foreach($packingLists as $packingList){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$filter = '["PoID:=%js%'.$packingList->reference.'"]';
|
|
||||||
|
|
||||||
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"Po","view":"grid1","request":{"PageIndex":-1,"PageSize":1000,"Filter":'.$filter.'}}'), '');
|
$filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]';
|
||||||
|
|
||||||
|
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||||
|
|
||||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||||
|
|
||||||
if(count($shippingPackingLists->Rows)) {
|
if(count($shippingPackingLists->Rows)) {
|
||||||
|
$packingList->packages()->delete();
|
||||||
|
|
||||||
} else {
|
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||||
dump($packingList->reference);
|
if($replica) $replica->packages()->delete();
|
||||||
|
|
||||||
|
foreach($shippingPackingLists->Rows as $shippingPackingList){
|
||||||
|
if(!$shippingPackingList[22]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$packageObject = new PackageObject(PackageType::CARTON, $shippingPackingList[19], $shippingPackingList[31], $shippingPackingList[30], $shippingPackingList[29], 0, $shippingPackingList[22], ApprovalStatus::APPROVED);
|
||||||
|
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (GuzzleException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
dd($exception);
|
|
||||||
Log::error($exception);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
|
|||||||
+52
-20
@@ -116,7 +116,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$start = $start ? $start : Carbon::today()->subDays(10);
|
$start = $start ? $start : Carbon::now()->subMonth();
|
||||||
|
|
||||||
$startLimit = Carbon::parse('11-08-2021');
|
$startLimit = Carbon::parse('11-08-2021');
|
||||||
|
|
||||||
@@ -124,44 +124,76 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
|||||||
$start = $startLimit;
|
$start = $startLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$end = $end ? $end : Carbon::today()->addDay();
|
$end = $end ? $end : Carbon::now();
|
||||||
|
|
||||||
$filter = '["ParcelDate:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]';
|
$filter = '["ParcelDate:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]';
|
||||||
|
|
||||||
$warehouseListRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"Parcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ParcelDate asc","Filter":'.$filter.'}}'), '');
|
$warehouseListRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ParcelDate asc","Filter":'.$filter.'}}'), '');
|
||||||
|
|
||||||
$response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest);
|
$response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest);
|
||||||
|
|
||||||
foreach ($response->Rows as $parcel){
|
foreach ($response->Rows as $parcel){
|
||||||
|
|
||||||
$allow_contract = true;
|
$marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $parcel[5]));
|
||||||
$marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $parcel[11]));
|
|
||||||
$orderNumber = $marking[array_key_last($marking)];
|
$orderNumber = $marking[array_key_last($marking)];
|
||||||
|
|
||||||
$quantity = $parcel[16];
|
if(!$parcel[9]){
|
||||||
|
|
||||||
if(!$quantity){
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$parcel[23] || !$parcel[22] || !$parcel[21]) continue;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
|
||||||
} catch (ResourceNotFoundException $exception) {
|
} catch (ResourceNotFoundException $exception) {
|
||||||
$allow_contract = false;
|
|
||||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
$oldOrder = OldOrders::where('marking', '=', $orderNumber)->first();
|
||||||
$appointee_id = 2037;
|
|
||||||
|
if(!$oldOrder){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$customerMarking = str_replace('/', '', str_replace(' ', '', explode('CIEF/', $oldOrder->company->marking)[1]));
|
||||||
|
|
||||||
|
$companyModule = CompanyModule::whereHas('inviters', function($query) use ($customerMarking) {
|
||||||
|
return $query->where('invitee_reference', '=', $customerMarking);
|
||||||
|
})->first();
|
||||||
|
|
||||||
|
|
||||||
|
if(!$companyModule){
|
||||||
|
log::error('unknown customer: '.$customerMarking);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$oldOrder->address) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var Address $address */
|
||||||
|
$address = $this->createAddressFromOldAddressProcessor->execute($oldOrder->address, $companyModule);
|
||||||
|
|
||||||
|
if(!$address){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$warehouseId = $parcel[0];
|
||||||
|
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]);
|
||||||
|
|
||||||
|
$order = $this->createOrderProcessor->execute($companyModule->company, $originWarehouse, $address, $orderNumber);
|
||||||
|
|
||||||
|
$order->created_at = Carbon::parse($parcel[1]);
|
||||||
|
$order->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$packingListReference = $parcel[0];
|
$packingListReference = $parcel[17];
|
||||||
// $measurement = round(($parcel[26]/$quantity) ** (1/3) * 100, 2);
|
$quantity = $parcel[9];
|
||||||
$description = $parcel[13];
|
$measurement = round(($parcel[10]/$quantity) ** (1/3) * 100, 2);
|
||||||
$tracking = $parcel[37];
|
$description = $parcel[7];
|
||||||
|
$tracking = $parcel[6];
|
||||||
$receiveDate = $parcel[1];
|
$receiveDate = $parcel[1];
|
||||||
|
|
||||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::APPROVED);
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
/** @var PackingList $packingList */
|
||||||
$packingList = $order->packingLists()->where('reference', '=', $packingListReference)->first();
|
$packingList = $order->packingLists()->where('reference', '=', $packingListReference)->first();
|
||||||
@@ -184,7 +216,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
|||||||
$packingList->packages()->delete();
|
$packingList->packages()->delete();
|
||||||
if($replica) $replica->packages()->delete();
|
if($replica) $replica->packages()->delete();
|
||||||
|
|
||||||
$packageObject = new PackageObject(PackageType::CARTON, $description, $parcel[23], $parcel[22], $parcel[21], 0, $quantity, ApprovalStatus::APPROVED);
|
$packageObject = new PackageObject(PackageType::CARTON, $description, $measurement, $measurement, $measurement, 0, $quantity, ApprovalStatus::APPROVED);
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||||
}
|
}
|
||||||
} catch (\Exception $exception){
|
} catch (\Exception $exception){
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Segments\Services\ListsSegments;
|
|
||||||
use App\Http\Resources\AirShipmentItemPriceResource;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ListAirShipmentPriceLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Retrieved Air Shipment Price List',
|
|
||||||
'message' => 'You have successfully retrieved a list of Air Shipment Price'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @var ListsSegments */
|
|
||||||
private $listsSegments;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ListSegmentLogic constructor.
|
|
||||||
* @param ListsSegments $listsSegments
|
|
||||||
*/
|
|
||||||
public function __construct(ListsSegments $listsSegments)
|
|
||||||
{
|
|
||||||
$this->listsSegments = $listsSegments;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
|
|
||||||
// $query = $this->listsSegments->execute($this->listsSegments->deserializeFilters($request->input('filters')));
|
|
||||||
|
|
||||||
// category - Dimension / perKg
|
|
||||||
$price = array(
|
|
||||||
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'Sound system speakers - MINI',
|
|
||||||
'pricePerKg' => '',
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => '',
|
|
||||||
'hasDimensionCharges' => '',
|
|
||||||
'tax' => '50',
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'Sound system speakers - SMALL',
|
|
||||||
'pricePerKg' => '',
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => '',
|
|
||||||
'hasDimensionCharges' => '',
|
|
||||||
'tax' => '200',
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'Sound system speakers - LARGE',
|
|
||||||
'pricePerKg' => '',
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => '',
|
|
||||||
'hasDimensionCharges' => '',
|
|
||||||
'tax' => '400',
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'Washing Machine - Dimension',
|
|
||||||
'pricePerKg' => '',
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => '',
|
|
||||||
'hasDimensionCharges' => 'true',
|
|
||||||
'tax' => '',
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'Oven, Balnder - perPcs',
|
|
||||||
'pricePerKg' => '',
|
|
||||||
'pricePerPcs' => '20',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => '',
|
|
||||||
'hasDimensionCharges' => '',
|
|
||||||
'tax' => '',
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'Perfume - perKg',
|
|
||||||
'pricePerKg' => '33',
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => '',
|
|
||||||
'hasDimensionCharges' => '',
|
|
||||||
'tax' => '',
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'Gold - Prohibited',
|
|
||||||
'pricePerKg' => '',
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => 'true',
|
|
||||||
'hasGram' => '',
|
|
||||||
'hasDimensionCharges' => '',
|
|
||||||
'tax' => '',
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'Food - hasGram',
|
|
||||||
'pricePerKg' => '',
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => 'true',
|
|
||||||
'hasDimensionCharges' => '',
|
|
||||||
'tax' => '',
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'TV 30" - 36"',
|
|
||||||
'pricePerKg' => 28,
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => 'true',
|
|
||||||
'hasDimensionCharges' => "true",
|
|
||||||
'tax' => 500,
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'TV 37" - 42"',
|
|
||||||
'pricePerKg' => 28,
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => 'true',
|
|
||||||
'hasDimensionCharges' => "true",
|
|
||||||
'tax' => 1000,
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'details' => json_encode([
|
|
||||||
'name' => 'TV 43"+"',
|
|
||||||
'pricePerKg' => 28,
|
|
||||||
'pricePerPcs' => '',
|
|
||||||
'isProhibited' => '',
|
|
||||||
'hasGram' => 'true',
|
|
||||||
'hasDimensionCharges' => "true",
|
|
||||||
'tax' => 1500,
|
|
||||||
])
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->collectionResponse(AirShipmentItemPriceResource::collection($price));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -112,7 +112,7 @@ class UpdateConstantLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$constantObject = [];
|
$constantObject = [];
|
||||||
|
|
||||||
$constantObject[$request->input('id')] = $request->input('value');
|
$constantObject[$request->input('id')] = $request->input('rate');
|
||||||
|
|
||||||
$object = new ConstantObject(
|
$object = new ConstantObject(
|
||||||
$request->input('reference'),
|
$request->input('reference'),
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
|||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification():array {
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Postcode Constant',
|
'title' => 'Updated Segment Constant',
|
||||||
'message' => 'You have successfully updated the Postcode Constant'
|
'message' => 'You have successfully updated the Segment Constant'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ class UpdateSegmentLogic extends AbstractControllerLogic
|
|||||||
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
$segment_object = new SegmentObject(
|
$segment_object = new SegmentObject(
|
||||||
$request->input('name'),
|
$request->input('name', $segment_query->name)
|
||||||
$segment_query->company_module_id
|
|
||||||
);
|
);
|
||||||
$this->canUpdateSegment->passes($segment_object);
|
$this->canUpdateSegment->passes($segment_object);
|
||||||
$segment_query = $this->updatesSegment->execute($segment_query, $segment_object);
|
$segment_query = $this->updatesSegment->execute($segment_query, $segment_object);
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
<?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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -7,9 +7,9 @@ class UpdatesConstantValue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $json
|
* @param $json
|
||||||
* @param int $state_id
|
* @param int $status_id
|
||||||
* @param array $rate
|
* @param Array $rate
|
||||||
* @return array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
public function execute($json, int $state_id, Array $rate) {
|
public function execute($json, int $state_id, Array $rate) {
|
||||||
|
|
||||||
|
|||||||
+5
-35
@@ -9,8 +9,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||||
use App\Classes\Modules\Documents\Services\RejectsDocument;
|
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\FetchesTransaction;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
|
|
||||||
@@ -22,22 +20,20 @@ use Illuminate\Http\Request;
|
|||||||
class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* ApprovePaymentTransactionLogic constructor.
|
* ApprovePaymentVerificationLogic constructor.
|
||||||
* @param FetchesTransaction $fetchesTransaction
|
* @param FetchesTransaction $fetchesTransaction
|
||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
* @param ApprovesDocument $approvesDocument
|
* @param ApprovesDocument $approvesDocument
|
||||||
* @param RejectsDocument $rejectsDocument
|
* @param RejectsDocument $rejectsDocument
|
||||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
* @param FetchesDocument $fetchesDocument
|
||||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument)
|
||||||
{
|
{
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
$this->fetchesTransaction = $fetchesTransaction;
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
$this->approvesDocument = $approvesDocument;
|
$this->approvesDocument = $approvesDocument;
|
||||||
$this->rejectsDocument = $rejectsDocument;
|
$this->rejectsDocument = $rejectsDocument;
|
||||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
|
||||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,18 +58,10 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
|||||||
/** @var RejectsDocument */
|
/** @var RejectsDocument */
|
||||||
private $rejectsDocument;
|
private $rejectsDocument;
|
||||||
|
|
||||||
/** @var UpdateDoFromVTPortalProcessor */
|
|
||||||
private $updateDoFromVTPortalProcessor;
|
|
||||||
|
|
||||||
/** @var UpdateDoFromYDPortalProcessor */
|
|
||||||
private $updateDoFromYDPortalProcessor ;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\InternalServerErrorException
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
@@ -86,25 +74,7 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->updatesTransactionStatus->execute($transaction, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
$this->updatesTransactionStatus->execute($transaction, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||||
|
|
||||||
if($transaction->status === ApprovalStatus::APPROVED){
|
// $this->createInvoiceTransactionProcessor->execute($transaction->booking);
|
||||||
$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([]);
|
return $this->response([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-98
@@ -1,98 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
|
||||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
|
||||||
use App\Classes\Modules\Transactions\ControllersLogic\Document;
|
|
||||||
|
|
||||||
class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Shipping Invoice Status',
|
|
||||||
'message' => 'You have successfully updated the shipping invoice status'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var FetchesPackingList */
|
|
||||||
private $fetchesPackingList;
|
|
||||||
|
|
||||||
/** @var UpdatesTransactionStatus */
|
|
||||||
private $updatesTransactionStatus;
|
|
||||||
|
|
||||||
/** @var CreatesDocument */
|
|
||||||
private $createsDocument;
|
|
||||||
|
|
||||||
/** @var CreatesFiles */
|
|
||||||
private $createsFiles;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ApprovePaymentVerificationLogic constructor.
|
|
||||||
* @param FetchesPackingList $fetchesPackingList
|
|
||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
|
||||||
* @param CreatesDocument $createsDocument
|
|
||||||
* @param CreatesFiles $createsFiles
|
|
||||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
|
||||||
{
|
|
||||||
$this->fetchesPackingList = $fetchesPackingList;
|
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
|
||||||
$this->createsDocument = $createsDocument;
|
|
||||||
$this->createsFiles = $createsFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
$invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
|
||||||
|
|
||||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
|
||||||
DocumentType::SHIPPING_INVOICE,
|
|
||||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
|
||||||
'',
|
|
||||||
ApprovalStatus::COMPLETED,
|
|
||||||
'shipping_invoice'
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @var Document $document */
|
|
||||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
|
||||||
|
|
||||||
$this->createsFiles->execute($document, $document_object);
|
|
||||||
$user = $packing_list->owner->companyModule->employees()->first();
|
|
||||||
if(app()->environment(['production'])) {
|
|
||||||
$user->notify(new InvoiceIssuedEmail($user, $packing_list));
|
|
||||||
}
|
|
||||||
return $this->response([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,6 @@ use App\Classes\ValueObjects\Constants\TransactionType;
|
|||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
|
||||||
use App\Http\Resources\TransactionResource;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
@@ -84,12 +83,9 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
|||||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||||
$billPlzBill = $this->createsBillplzBill->execute(
|
$billPlzBill = $this->createsBillplzBill->execute(
|
||||||
$company_module->name,
|
$company_module->name,
|
||||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
$company_module->employees()->first()->email,
|
||||||
'This payment is for the invoice number . ' . $invoice_transaction->bill_no,
|
'This payment is credit topup for company ref. ' . $company_module->reference, $amount, $billNumber,
|
||||||
$amount,
|
$request->input('bank_code'), true
|
||||||
$billNumber,
|
|
||||||
$request->input('bank_code'),
|
|
||||||
true
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$payment_reference = $billPlzBill->id;
|
$payment_reference = $billPlzBill->id;
|
||||||
@@ -120,6 +116,6 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
||||||
|
|
||||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
return $this->response([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-77
@@ -16,7 +16,6 @@ use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject
|
|||||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
@@ -25,9 +24,7 @@ use App\Classes\ValueObjects\Constants\PackageType;
|
|||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||||
|
|
||||||
use App\Models\CompanyModule;
|
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -94,23 +91,16 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||||
$packing_list = PackingList::where('reference', $packing_list->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first();
|
|
||||||
|
|
||||||
$billable_packing_list = $packing_list->packingLists()->first();
|
$cbm = $packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||||
|
|
||||||
$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);
|
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||||
}), 3);
|
});
|
||||||
|
|
||||||
$over_weight_cbm = round($billable_packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
$over_weight_cbm = $packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||||
}), 3);
|
});
|
||||||
|
|
||||||
$order = $packing_list->owner;
|
$order = $packing_list->owner;
|
||||||
$companyModule = $order->companyModule;
|
|
||||||
$connection = $companyModule->connections()->first();
|
|
||||||
$address = $order->addresses()->first();
|
$address = $order->addresses()->first();
|
||||||
|
|
||||||
$base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]);
|
$base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]);
|
||||||
@@ -119,20 +109,12 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
$center_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::CENTER_POSTCODE]);
|
$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]);
|
$outstation_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::OUTSTATION_POSTCODE]);
|
||||||
|
|
||||||
$noMinimumCharge = $connection->segments()->where('segments.id', 2)->first();
|
$base_price = 0;
|
||||||
|
$warehouse_rate = 0;
|
||||||
$minimum_cbm = 0.3;
|
$state_rate = 0;
|
||||||
$state_select = '';
|
$state_select = '';
|
||||||
|
|
||||||
$segment_price = $connection->segments()->whereHas('constants', function($query){
|
$base_price = $this->getConstantByKey($base_price_constant, date('Y-m-d'));
|
||||||
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;
|
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
|
||||||
$selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId);
|
$selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId);
|
||||||
@@ -148,45 +130,8 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
$state_rate_constant = (array)$state_rate_constant;
|
$state_rate_constant = (array)$state_rate_constant;
|
||||||
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
|
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
|
||||||
|
|
||||||
$container = $packing_list->containers()->first();
|
$price_cbm = $base_price + $warehouse_rate + $state_rate;
|
||||||
$containerPackingLists = collect();
|
$total_cbm = $price_cbm * ($cbm + $over_weight_cbm);
|
||||||
$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 + $minimum_charge + $over_weight_cbm);
|
|
||||||
|
|
||||||
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
||||||
|
|
||||||
@@ -205,7 +150,7 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
ApprovalStatus::PENDING_SUBMISSION
|
ApprovalStatus::PENDING_VERIFICATION
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var Transaction $invoice_transaction */
|
/** @var Transaction $invoice_transaction */
|
||||||
@@ -213,7 +158,7 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$object_detail = new TransactionDetailObject(
|
$object_detail = new TransactionDetailObject(
|
||||||
'SHIPPING_FEE',
|
'SHIPPING_FEE',
|
||||||
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
TransactionDetailType::SHIPPING_FEE,
|
||||||
$cbm,
|
$cbm,
|
||||||
$price_cbm
|
$price_cbm
|
||||||
);
|
);
|
||||||
@@ -231,16 +176,20 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($minimum_charge > 0) {
|
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||||
$object_detail = new TransactionDetailObject(
|
|
||||||
'MIN_CBM_CHARGES',
|
|
||||||
TransactionDetailType::MIN_CBM_CHARGES,
|
|
||||||
$minimum_charge,
|
|
||||||
$price_cbm
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$document_object = new DocumentObject(
|
||||||
}
|
DocumentType::SHIPPING_INVOICE,
|
||||||
|
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||||
|
'',
|
||||||
|
ApprovalStatus::COMPLETED,
|
||||||
|
'shipping_invoice'
|
||||||
|
);
|
||||||
|
|
||||||
|
/** @var Document $document */
|
||||||
|
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||||
|
|
||||||
|
$this->createsFile->execute($document, $document_object);
|
||||||
|
|
||||||
return $this->response([]);
|
return $this->response([]);
|
||||||
}
|
}
|
||||||
@@ -249,7 +198,6 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
if ($segmentConstantObject) {
|
if ($segmentConstantObject) {
|
||||||
$base_rate = (array) $segmentConstantObject->value;
|
$base_rate = (array) $segmentConstantObject->value;
|
||||||
$base_rate = array_key_exists($key, $base_rate) === true ? $base_rate[$key] : 0;
|
$base_rate = array_key_exists($key, $base_rate) === true ? $base_rate[$key] : 0;
|
||||||
|
|
||||||
return $base_rate;
|
return $base_rate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-92
@@ -1,92 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
|
|
||||||
use App\Models\District;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\General\Helper;
|
|
||||||
|
|
||||||
class ShippingEstimationCalculatorLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var FetchesSegmentConstant */
|
|
||||||
private $fetchesSegmentConstant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Shipping estimation',
|
|
||||||
'message' => 'You have successfully calculate the Shipping Estimation'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
FetchesSegmentConstant $fetchesSegmentConstant
|
|
||||||
){
|
|
||||||
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$base_price = $warehouse_rate = $state_rate = 0;
|
|
||||||
|
|
||||||
$width = $request->input('width') / 100; // metre
|
|
||||||
$length = $request->input('length') / 100; // metre
|
|
||||||
$height = $request->input('height') / 100; // metre
|
|
||||||
|
|
||||||
$cbm = (float) ($width * $length * $height);
|
|
||||||
|
|
||||||
// calculate base price
|
|
||||||
$base_prices = $this->getSegmentConstantData(SegmentConstants::BASE_PRICE);
|
|
||||||
$base_price = $this->getConstantDataUsingKey($base_prices, date('Y-m-d'));
|
|
||||||
|
|
||||||
// calculate warehouse rate
|
|
||||||
$warehouse_prices = $this->getSegmentConstantData(SegmentConstants::WAREHOUSE_RATE);
|
|
||||||
$warehouse_rate = $this->getConstantDataUsingKey($warehouse_prices, $request->input('warehouse_id'), 'amount');
|
|
||||||
|
|
||||||
// calculate applied state rate
|
|
||||||
$state_prices = $this->getSegmentConstantData(SegmentConstants::STATE_RATE);
|
|
||||||
$outstation_postcodes = $this->getSegmentConstantData(SegmentConstants::OUTSTATION_POSTCODE);
|
|
||||||
|
|
||||||
$district = District::where('postcode','LIKE','%'.$request->input('postcode').'%')->first();
|
|
||||||
if(array_search($request->input('postcode'), $outstation_postcodes)!==false){
|
|
||||||
$state_rate = $this->getConstantDataUsingKey($state_prices, $district->state_id, 'outstation');
|
|
||||||
}
|
|
||||||
|
|
||||||
$price_cbm = $base_price + $warehouse_rate + $state_rate;
|
|
||||||
$total_price_cbm = $price_cbm * $cbm;
|
|
||||||
|
|
||||||
return $this->response([
|
|
||||||
'cbm' => $cbm, 'base_price' => $base_price, 'warehouse_rate' => $warehouse_rate,
|
|
||||||
'state_rate' => $state_rate, 'total_price_cbm' => $total_price_cbm
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getConstantDataUsingKey($data, $search_key, $field='')
|
|
||||||
{
|
|
||||||
if(array_key_exists($search_key, $data) !== true) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
if($field!=''){
|
|
||||||
return $data[$search_key]->$field;
|
|
||||||
} else {
|
|
||||||
return $data[$search_key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getSegmentConstantData($reference)
|
|
||||||
{
|
|
||||||
$data = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => $reference]);
|
|
||||||
return (array) $data->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -50,9 +50,9 @@ class SuspendTransactionLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
$transaction = $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::SUSPENDED);
|
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::SUSPENDED);
|
||||||
|
|
||||||
return $this->resourceResponse(new TransactionResource($transaction));
|
return $this->response([]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-147
@@ -1,147 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
|
||||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransaction;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransactionDetail;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionDetail;
|
|
||||||
use App\Classes\Modules\Transactions\Services\DeletesTransactionDetails;
|
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
|
||||||
|
|
||||||
class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Update Shipping Invoice Transaction',
|
|
||||||
'message' => 'You have successfully update shipping invoice transaction'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var FetchesPackingList */
|
|
||||||
private $fetchesPackingList;
|
|
||||||
|
|
||||||
/** @var FetchesTransaction */
|
|
||||||
private $fetchesTransaction;
|
|
||||||
|
|
||||||
/** @var UpdatesTransaction */
|
|
||||||
private $updatesTransaction;
|
|
||||||
|
|
||||||
/** @var FetchesTransactionDetail */
|
|
||||||
private $fetchesTransactionDetail;
|
|
||||||
|
|
||||||
/** @var CreatesTransactionDetail */
|
|
||||||
private $createsTransactionDetail;
|
|
||||||
|
|
||||||
/** @var UpdatesTransactionDetail */
|
|
||||||
private $updatesTransactionDetail;
|
|
||||||
|
|
||||||
/** @var DeletesTransactionDetails */
|
|
||||||
private $deletesTransactionDetails;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
FetchesPackingList $fetchesPackingList,
|
|
||||||
FetchesTransaction $fetchesTransaction,
|
|
||||||
UpdatesTransaction $updatesTransaction,
|
|
||||||
FetchesTransactionDetail $fetchesTransactionDetail,
|
|
||||||
CreatesTransactionDetail $createsTransactionDetail,
|
|
||||||
UpdatesTransactionDetail $updatesTransactionDetail,
|
|
||||||
DeletesTransactionDetails $deletesTransactionDetails
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->fetchesPackingList = $fetchesPackingList;
|
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
|
||||||
$this->updatesTransaction = $updatesTransaction;
|
|
||||||
$this->fetchesTransactionDetail = $fetchesTransactionDetail;
|
|
||||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
|
||||||
$this->updatesTransactionDetail = $updatesTransactionDetail;
|
|
||||||
$this->deletesTransactionDetails = $deletesTransactionDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
$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'));
|
|
||||||
|
|
||||||
$total_cbm = $invoice_transaction->amount;
|
|
||||||
|
|
||||||
foreach($old_transaction_details as $old_transaction_detail_id){
|
|
||||||
$old_transaction_detail = $this->fetchesTransactionDetail->execute(['id' => $old_transaction_detail_id]);
|
|
||||||
|
|
||||||
$total_cbm -= $old_transaction_detail->price;
|
|
||||||
|
|
||||||
if(!$new_transaction_details->contains('id', $old_transaction_detail_id)){
|
|
||||||
$this->deletesTransactionDetails->execute($old_transaction_detail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($new_transaction_details as $transaction_detail){
|
|
||||||
$transaction_detail = (object) $transaction_detail;
|
|
||||||
|
|
||||||
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,
|
|
||||||
$transaction_detail->quantity,
|
|
||||||
$transaction_detail->price
|
|
||||||
);
|
|
||||||
|
|
||||||
if(isset($transaction_detail->id)){
|
|
||||||
$new_transaction_detail = $this->updatesTransactionDetail->execute($this->fetchesTransactionDetail->execute(['id' => $transaction_detail->id]), $object_detail);
|
|
||||||
}else{
|
|
||||||
$new_transaction_detail = $this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$object = new TransactionObject(
|
|
||||||
$invoice_transaction->bill_no,
|
|
||||||
TransactionType::SHIPPING_INVOICE,
|
|
||||||
1,
|
|
||||||
$invoice_transaction->issuer,
|
|
||||||
1,
|
|
||||||
PaymentMethodType::CASH,
|
|
||||||
$invoice_transaction->transactionDetails()->sum('amount'),
|
|
||||||
$invoice_transaction->transactionDetails()->sum('amount'),
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
null,
|
|
||||||
ApprovalStatus::PENDING_VERIFICATION
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @var Transaction $invoice_transaction */
|
|
||||||
$invoice_transaction = $this->updatesTransaction->execute($invoice_transaction, $object);
|
|
||||||
|
|
||||||
return $this->response([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?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,7 +22,6 @@ class CreatesPaymentTransaction extends AbstractUpdateRelationshipRecord
|
|||||||
$model->receiver = $object->getReceiver();
|
$model->receiver = $object->getReceiver();
|
||||||
$model->recipient_bank_account_id = $object->getRecipientBankAccountId();
|
$model->recipient_bank_account_id = $object->getRecipientBankAccountId();
|
||||||
$model->payment_method = $object->getPaymentMethod();
|
$model->payment_method = $object->getPaymentMethod();
|
||||||
$model->payment_reference = $object->getPaymentReference();
|
|
||||||
$model->amount = $object->getAmount();
|
$model->amount = $object->getAmount();
|
||||||
$model->original_amount = $object->getOriginalAmount();
|
$model->original_amount = $object->getOriginalAmount();
|
||||||
$model->currency_id = $object->getCurrencyId();
|
$model->currency_id = $object->getCurrencyId();
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
namespace App\Classes\Modules\Transactions\Services;
|
namespace App\Classes\Modules\Transactions\Services;
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||||
use App\Models\TransactionDetail;
|
use App\Models\Transaction;
|
||||||
|
|
||||||
class DeletesTransactionDetails extends AbstractDeleteRecord
|
class DeletesTransactionDetails extends AbstractDeleteRecord
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionDetail $model
|
* @param Transaction $model
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function execute(TransactionDetail $model) {
|
public function execute(Transaction $model) {
|
||||||
return $model->delete();
|
return $model->transactionDetails()->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\Services;
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
|
||||||
use App\Models\TransactionDetail;
|
|
||||||
|
|
||||||
class UpdatesTransactionDetail extends AbstractUpdateRecord
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param TransactionDetail $transactionDetail
|
|
||||||
* @param TransactionDetailObject $object
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(TransactionDetail $transactionDetail, TransactionDetailObject $object) {
|
|
||||||
$transactionDetail->reference = $object->getReference();
|
|
||||||
$transactionDetail->name = $object->getName();
|
|
||||||
$transactionDetail->quantity = $object->getQuantity();
|
|
||||||
$transactionDetail->price = $object->getPrice();
|
|
||||||
$transactionDetail->amount = $object->getAmount();
|
|
||||||
|
|
||||||
return $this->handler($transactionDetail);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,13 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Classes\Notifications;
|
namespace App\Classes\Notifications;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class AbstractEmail extends Notification implements ShouldQueue
|
class AbstractEmail extends Notification
|
||||||
{
|
{
|
||||||
use Queueable;
|
|
||||||
|
|
||||||
public function via()
|
public function via()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
<?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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?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)
|
return (new MailMessage)
|
||||||
->subject('Email Verification')
|
->subject('Email Verification')
|
||||||
->bcc(['email_test@cief-malaysia.com'])->view('emails.accounts.user_verification', ['user' => $this->user, 'attempt' => $this->attempt]);
|
->view('emails.accounts.user_verification', ['user' => $this->user, 'attempt' => $this->attempt]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,16 +14,12 @@ class FileType
|
|||||||
|
|
||||||
public const PDF = 'application/pdf';
|
public const PDF = 'application/pdf';
|
||||||
|
|
||||||
public const EXCEL = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
||||||
|
|
||||||
public const EXTENSION = [
|
public const EXTENSION = [
|
||||||
'image/gif' => 'gif',
|
'image/gif' => 'gif',
|
||||||
'image/png' => 'png',
|
'image/png' => 'png',
|
||||||
'image/jpeg' => 'jpeg',
|
'image/jpeg' => 'jpeg',
|
||||||
'application/pdf' => 'pdf',
|
'application/pdf' => 'pdf',
|
||||||
'application/octet-stream' => 'pdf',
|
'application/octet-stream' => 'pdf',
|
||||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'excel',
|
|
||||||
'application/vnd.ms-excel' => 'excel',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,6 @@ class SegmentConstants
|
|||||||
|
|
||||||
public const BASE_PRICE = 'BASE_PRICE';
|
public const BASE_PRICE = 'BASE_PRICE';
|
||||||
|
|
||||||
public const CUSTOM_PRICE = 'CUSTOM_PRICE';
|
|
||||||
|
|
||||||
public const WAREHOUSE_RATE = 'WAREHOUSE_RATE';
|
public const WAREHOUSE_RATE = 'WAREHOUSE_RATE';
|
||||||
|
|
||||||
public const STATE_RATE = 'STATE_RATE';
|
public const STATE_RATE = 'STATE_RATE';
|
||||||
|
|||||||
@@ -4,11 +4,7 @@ namespace App\Classes\ValueObjects\Constants;
|
|||||||
|
|
||||||
final class TransactionDetailType {
|
final class TransactionDetailType {
|
||||||
|
|
||||||
public const SHIPPING_FEE = 'X1 Freight Service Charge';
|
public const SHIPPING_FEE = 'Shipping Fee';
|
||||||
|
|
||||||
public const OVER_WEIGHT_CHARGES = 'Overweight Charges';
|
public const OVER_WEIGHT_CHARGES = 'Over weight charges';
|
||||||
|
|
||||||
public const MIN_CBM_CHARGES = 'Minimum Charge for 0.3 CBM Per Container';
|
|
||||||
|
|
||||||
public const CUSTOM_CHARGES = 'Custom charges';
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,9 @@ final class WarehouseReferences {
|
|||||||
|
|
||||||
public const YD_DESTINATION_WAREHOUSE = self::YD_KLANG;
|
public const YD_DESTINATION_WAREHOUSE = self::YD_KLANG;
|
||||||
|
|
||||||
public const YD_EXEMPT_LIST = [230, 294, 320, 1248, 1726, 2349, 2574];
|
public const YD_EXEMPT_LIST = [230, 294, 320, 652, 1248, 1726];
|
||||||
|
|
||||||
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
|
//2376 qce
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ class CurlVTCommand extends Command
|
|||||||
{
|
{
|
||||||
return FetchWarehouseReceiveListFromVTPortalJob::withChain([
|
return FetchWarehouseReceiveListFromVTPortalJob::withChain([
|
||||||
new FetchLoadedContainersFromVTPortalJob,
|
new FetchLoadedContainersFromVTPortalJob,
|
||||||
|
new FetchPackingListFromVTPortalJob,
|
||||||
|
new FetchContainersStatusUpdateFromVTPortalJob,
|
||||||
|
new FetchDeliveryListFromVTPortalJob
|
||||||
])->dispatch();
|
])->dispatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
<?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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,7 +29,7 @@ class Kernel extends ConsoleKernel
|
|||||||
{
|
{
|
||||||
|
|
||||||
$schedule->command('command:curlVTCommand')
|
$schedule->command('command:curlVTCommand')
|
||||||
->cron('0 8 * * *')
|
->cron('0 9-18/3 * * *')
|
||||||
->withoutOverlapping()
|
->withoutOverlapping()
|
||||||
->appendOutputTo (storage_path().'/logs/curlvt.log');
|
->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||||
|
|
||||||
@@ -38,11 +38,6 @@ class Kernel extends ConsoleKernel
|
|||||||
->withoutOverlapping()
|
->withoutOverlapping()
|
||||||
->appendOutputTo (storage_path().'/logs/curlyd.log');
|
->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||||
|
|
||||||
$schedule->command('command:curlYdOrderListCommand')
|
|
||||||
->cron('0 9 * * *')
|
|
||||||
->withoutOverlapping()
|
|
||||||
->appendOutputTo (storage_path().'/logs/departure_email.log');
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+1
-1
@@ -10,7 +10,7 @@ class AssignCompanyConnectionToConnectionSegmentController
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param AssignCompanyConnectionToConnectionSegmentLogic $logic
|
* @param AssignCompanyToSegmentLogic $logic
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function assign(Request $request, AssignCompanyConnectionToConnectionSegmentLogic $logic): JsonResponse {
|
public function assign(Request $request, AssignCompanyConnectionToConnectionSegmentLogic $logic): JsonResponse {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Controllers\Exports;
|
namespace App\Http\Controllers\Exports;
|
||||||
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsArrivedParcel;
|
use App\Classes\Modules\Exports\Services\ExportsArrivedParcel;
|
||||||
use App\Classes\Modules\Exports\Services\ExportsParcel;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@@ -27,11 +26,4 @@ class ExportArrivedParcelController
|
|||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
return $response;
|
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,13 +4,10 @@ namespace App\Http\Controllers\Exports;
|
|||||||
|
|
||||||
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsCustomersOrderLatestDate;
|
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 App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Maatwebsite\Excel\Excel;
|
use Maatwebsite\Excel\Excel;
|
||||||
use App\Classes\Modules\Exports\Services\ExportsNullDebtors;
|
|
||||||
|
|
||||||
class ExportCustomersToExcelController
|
class ExportCustomersToExcelController
|
||||||
{
|
{
|
||||||
@@ -19,24 +16,4 @@ class ExportCustomersToExcelController
|
|||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||||
return $exportsCustomers->download('customer-latest-order-date.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?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 [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\PackingLists\Packages;
|
namespace App\Http\Controllers\PackingLists\Containers;
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\ControllersLogic\Containers\InboundCustomClearedLogic;
|
use App\Classes\Modules\PackingLists\ControllersLogic\Containers\InboundCustomClearedLogic;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Segments;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Segments\ControllersLogic\ListAirShipmentPriceLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ListAirShipmentPriceController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param ListSegmentLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function list(Request $request, ListAirShipmentPriceLogic $logic): JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Transactions;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Transactions\ControllersLogic\ApproveShippingInvoiceTransactionLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ApproveShippingInvoiceTransactionController
|
|
||||||
{
|
|
||||||
|
|
||||||
public function approve(Request $request, ApproveShippingInvoiceTransactionLogic $logic): JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Transactions;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Transactions\ControllersLogic\ShippingEstimationCalculatorLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ShippingEstimationCalculatorController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param ShippingEstimationCalculatorLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function calculate(Request $request, ShippingEstimationCalculatorLogic $logic): JsonResponse
|
|
||||||
{
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Transactions;
|
|
||||||
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\Modules\Transactions\ControllersLogic\UpdateShippingInvoiceTransactionLogic;
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateShippingInvoiceTransactionController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param UpdateShippingInvoiceTransactionLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(Request $request, UpdateShippingInvoiceTransactionLogic $logic) : JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?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();
|
$centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get();
|
||||||
$centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value;
|
$centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value;
|
||||||
$postcodeArea = in_array((String)$this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : null;
|
$postcodeArea = in_array($this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : '';
|
||||||
|
|
||||||
$outstationPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::OUTSTATION_POSTCODE)->get();
|
$outstationPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::OUTSTATION_POSTCODE)->get();
|
||||||
$outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value;
|
$outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value;
|
||||||
in_array((String)$this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : null;
|
in_array($this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : '';
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
@@ -34,7 +34,6 @@ class AddressResource extends JsonResource
|
|||||||
'street_two' => $this->street_two,
|
'street_two' => $this->street_two,
|
||||||
'district' => $this->district,
|
'district' => $this->district,
|
||||||
'state' => $this->state,
|
'state' => $this->state,
|
||||||
'postcode' => $this->postcode,
|
|
||||||
'post_code' => $this->postcode,
|
'post_code' => $this->postcode,
|
||||||
'post_code_area' => $postcodeArea,
|
'post_code_area' => $postcodeArea,
|
||||||
'country' => $this->country,
|
'country' => $this->country,
|
||||||
@@ -42,7 +41,6 @@ class AddressResource extends JsonResource
|
|||||||
'status' => (int) $this->status,
|
'status' => (int) $this->status,
|
||||||
'contact' => new ContactResource($this->contacts->first()),
|
'contact' => new ContactResource($this->contacts->first()),
|
||||||
'remark' => new RemarkResource($this->remarks->first()),
|
'remark' => new RemarkResource($this->remarks->first()),
|
||||||
'type' => $this->type,
|
|
||||||
$this->mergeWhen($this->relationLoaded('owner'), [
|
$this->mergeWhen($this->relationLoaded('owner'), [
|
||||||
'owner' => $this->when($this->owner instanceof Order, [
|
'owner' => $this->when($this->owner instanceof Order, [
|
||||||
'reference' => $this->owner->reference,
|
'reference' => $this->owner->reference,
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
|
||||||
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
|
|
||||||
class AirShipmentItemPriceResource extends JsonResource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
|
||||||
$object = $this->resource;
|
|
||||||
$detailsArray = (array)json_decode($object['details']);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => $detailsArray['name'],
|
|
||||||
'details' => $object['details'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyServices;
|
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\BankAccountType;
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||||
@@ -43,12 +41,10 @@ class CompanyModuleResource extends JsonResource
|
|||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'reference' => $this->reference,
|
'reference' => $this->reference,
|
||||||
'address' => new AddressResource($defaultAddress),
|
'address' => new AddressResource($defaultAddress),
|
||||||
'billingAddress' => new AddressResource($this->addresses()->where('type', AddressType::BILLING)->where('status', ApprovalStatus::APPROVED)->first()),
|
|
||||||
'company' => new CompanyResource($this->whenLoaded('company')),
|
'company' => new CompanyResource($this->whenLoaded('company')),
|
||||||
'remarks' => RemarkResource::collection($this->remarks),
|
'remarks' => RemarkResource::collection($this->remarks),
|
||||||
'marking' => $marking,
|
'marking' => $marking,
|
||||||
'warehouseCharges' => array_key_exists($this->id, $segmentConstant) ? $segmentConstant[$this->id] : null,
|
'warehouseCharges' => array_key_exists($this->id, $segmentConstant) ? $segmentConstant[$this->id] : null,
|
||||||
'connections' => $this->connections,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class CompanyResource extends JsonResource
|
|||||||
'type' => (int) $this->type,
|
'type' => (int) $this->type,
|
||||||
'business_type' => (int) $this->business_type,
|
'business_type' => (int) $this->business_type,
|
||||||
'status' => (int) $this->status,
|
'status' => (int) $this->status,
|
||||||
'segments' => SegmentResource::collection($companyModule->connections()->first()->segments),
|
|
||||||
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
|
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
|
||||||
'employee' => new UserResource($companyModule->employees()->first()),
|
'employee' => new UserResource($companyModule->employees()->first()),
|
||||||
'company_module' => new CompanyModuleResource($companyModule),
|
'company_module' => new CompanyModuleResource($companyModule),
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ContainerResource extends JsonResource
|
|||||||
'remarks' => RemarkResource::collection($this->remarks),
|
'remarks' => RemarkResource::collection($this->remarks),
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'packing_lists' => $this->whenLoaded('packingLists', PackingListResource::collection($this->whenLoaded('packingLists', function(){
|
'packing_lists' => $this->whenLoaded('packingLists', PackingListResource::collection($this->whenLoaded('packingLists', function(){
|
||||||
return $this->packingLists()->get()->sortBy(function ($packingList) {
|
return $this->packingLists()->whereHas('packages')->get()->sortBy(function ($packingList) {
|
||||||
return $packingList->owner->company_module_id;
|
return $packingList->owner->company_module_id;
|
||||||
});
|
});
|
||||||
})))
|
})))
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ class OrderResource extends JsonResource
|
|||||||
'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->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),
|
'remarks' => RemarkResource::collection($this->remarks),
|
||||||
'created_at' => $this->created_at->format('d-m-Y')
|
'created_at' => $this->created_at->format('d-m-Y')
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class PackageResource extends JsonResource
|
|||||||
'weight' => $this->weight,
|
'weight' => $this->weight,
|
||||||
'quantity' => $this->quantity,
|
'quantity' => $this->quantity,
|
||||||
'cbm' => (($this->width / 100) * ($this->height / 100) * ($this->length / 100)) * $this->quantity,
|
'cbm' => (($this->width / 100) * ($this->height / 100) * ($this->length / 100)) * $this->quantity,
|
||||||
'reference' => $this->packingList->reference,
|
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
$this->mergeWhen($originalPackingList->owner instanceof Order, [
|
$this->mergeWhen($originalPackingList->owner instanceof Order, [
|
||||||
'order' => New OrderResource($originalPackingList->owner)
|
'order' => New OrderResource($originalPackingList->owner)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
@@ -35,9 +34,7 @@ class PackingListResource extends JsonResource
|
|||||||
$this->mergeWhen($this->owner instanceof Order, [
|
$this->mergeWhen($this->owner instanceof Order, [
|
||||||
'order' => New OrderResource($this->owner)
|
'order' => New OrderResource($this->owner)
|
||||||
]),
|
]),
|
||||||
'shipping_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()),
|
'shippng_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->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()),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ class SegmentResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
$constant = $this->constants->where('reference', SegmentConstants::CUSTOM_PRICE)->first();
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'price' => $constant ? $constant->value[0] : 0
|
// 'time_limit' => $this->when($this->whereHas('constants', function($query){
|
||||||
|
// $query->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT);
|
||||||
|
// }), $this->constants->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT)->first()),
|
||||||
|
// 'services' => CustomServiceTypeResource::collection($this->constants->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ class TransactionDetailResource extends JsonResource
|
|||||||
{
|
{
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'reference' => $this->reference,
|
'stockCode' => $this->product_code,
|
||||||
|
'description' => $this->product_name,
|
||||||
'quantity' => $this->quantity,
|
'quantity' => $this->quantity,
|
||||||
'price' => (double) $this->price,
|
'unit_price' => (double) $this->price,
|
||||||
'name' => $this->name,
|
'total' => (double) $this->amount
|
||||||
'amount' => (double) $this->amount
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\Resources;
|
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 Carbon\Carbon;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
@@ -20,41 +15,22 @@ class TransactionResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'order' => ($this->owner instanceof Transaction) ? new OrderResource($this->owner->owner->owner) : new OrderResource($this->owner->owner),
|
// 'booking' => new BookingResource($this->booking),
|
||||||
'documents' => DocumentResource::collection($this->documents),
|
|
||||||
'type' => (int) $this->type,
|
'type' => (int) $this->type,
|
||||||
'bill_no' => $this->bill_no,
|
'bill_no' => $this->bill_no,
|
||||||
'amount' => (double) $this->amount,
|
'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,
|
'original_amount' => (double) $this->original_amount,
|
||||||
'currency' => new CurrencyResource($this->currency),
|
'currency' => new CurrencyResource($this->currency),
|
||||||
'original_currency' => new CurrencyResource($this->original_currency),
|
'original_currency' => new CurrencyResource($this->original_currency),
|
||||||
'currency_rate' => (double) $this->currency_rate,
|
'currency_rate' => (double) $this->currency_rate,
|
||||||
'status' => (int) $this->status,
|
'status' => (int) $this->status,
|
||||||
'details' => TransactionDetailResource::collection($this->transactionDetails),
|
'details' => TransactionDetailResource::collection($this->transactionDetails),
|
||||||
'transactions' => TransactionResource::collection($this->transactions),
|
'documents' => new DocumentResource($this->documents()->first()),
|
||||||
'payment_attempts' => TransactionResource::collection(
|
|
||||||
$this->transactions()
|
|
||||||
->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)
|
|
||||||
->get()
|
|
||||||
),
|
|
||||||
'payment_history' => TransactionResource::collection(
|
|
||||||
$this->transactions()
|
|
||||||
->payments()
|
|
||||||
->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'),
|
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:s:i'),
|
||||||
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y'),
|
'updated_at' => Carbon::parse($this->update_at)->format('d-m-Y h:s:i')
|
||||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y')
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<?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,15 +186,6 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
|
|||||||
return $this->morphMany(Remark::class, 'owner');
|
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,7 +4,6 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Classes\General\Interfaces\Remarkable;
|
use App\Classes\General\Interfaces\Remarkable;
|
||||||
use App\Classes\General\Interfaces\Transportable;
|
use App\Classes\General\Interfaces\Transportable;
|
||||||
use App\Classes\General\Traits\LogData;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
@@ -15,7 +14,6 @@ class Container extends AbstractModel implements Transportable, Remarkable
|
|||||||
{
|
{
|
||||||
use HasRelationships;
|
use HasRelationships;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use LogData;
|
|
||||||
|
|
||||||
protected $table = 'containers';
|
protected $table = 'containers';
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
|||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
|
||||||
|
|
||||||
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable
|
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use HasRelationships;
|
|
||||||
|
|
||||||
protected $table = 'orders';
|
protected $table = 'orders';
|
||||||
|
|
||||||
@@ -163,10 +160,10 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return hasManyDeep
|
* @return morphMany
|
||||||
*/
|
*/
|
||||||
public function transactions(): hasManyDeep
|
// public function transactions(): morphMany
|
||||||
{
|
// {
|
||||||
return $this->hasManyDeep(Transaction::class, [PackingList::class], ['owner_id', 'owner_id'], ['id', 'id']);
|
// return $this->morphMany(Transaction::class, 'owner');
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Classes\General\Interfaces\Transportable;
|
|||||||
use App\Classes\General\Interfaces\Packable;
|
use App\Classes\General\Interfaces\Packable;
|
||||||
use App\Classes\General\Interfaces\Transactionable;
|
use App\Classes\General\Interfaces\Transactionable;
|
||||||
|
|
||||||
use App\Classes\General\Traits\LogData;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
@@ -24,7 +23,6 @@ class PackingList extends AbstractModel implements Transportable, Steppable, Pac
|
|||||||
use HasTableAlias;
|
use HasTableAlias;
|
||||||
use HasRelationships;
|
use HasRelationships;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use LogData;
|
|
||||||
|
|
||||||
protected $table = 'packing_lists';
|
protected $table = 'packing_lists';
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\Documentable;
|
use App\Classes\General\Interfaces\Documentable;
|
||||||
use App\Classes\General\Interfaces\Remarkable;
|
|
||||||
use App\Classes\General\Interfaces\Transactionable;
|
use App\Classes\General\Interfaces\Transactionable;
|
||||||
use App\Classes\General\Traits\LogData;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -14,13 +12,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
||||||
|
|
||||||
class Transaction extends AbstractModel implements Documentable, Transactionable, Remarkable
|
class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
|
||||||
use LogData;
|
|
||||||
|
|
||||||
protected $table = 'transactions';
|
protected $table = 'transactions';
|
||||||
|
|
||||||
public function owner(): morphTo
|
public function owner(): morphTo
|
||||||
@@ -128,12 +122,4 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
|||||||
{
|
{
|
||||||
return $query->whereIn('status', [ApprovalStatus::COMPLETED]);
|
return $query->whereIn('status', [ApprovalStatus::COMPLETED]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MorphMany
|
|
||||||
*/
|
|
||||||
public function remarks(): morphMany
|
|
||||||
{
|
|
||||||
return $this->morphMany(Remark::class, 'owner');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user