fix ide-autospace formatting

This commit is contained in:
Martin Kiragu
2023-03-24 06:04:28 +03:00
parent ba26cda598
commit 362e47aaa0
9 changed files with 231 additions and 251 deletions
@@ -24,8 +24,7 @@ class ListDocumentLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification(): array
{
protected function notification():array {
return [
'title' => 'Retrieved Document',
'message' => 'You have successfully retrieved a list of Document'
@@ -57,15 +56,14 @@ class ListDocumentLogic extends AbstractControllerLogic
* @throws MalformedRequestException
* @throws RequestValidationException
*/
public function logic(Request $request): JsonResponse
public function logic(Request $request) : JsonResponse
{
$this->canListDocuments->passes();
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]
));
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
return $this->collectionResponse(DocumentResource::collection($query));
return $this->collectionResponse(DocumentResource::collection($query));
/* return fractal()
+4 -4
View File
@@ -13,7 +13,7 @@ class CompanyResource extends JsonResource
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
@@ -26,9 +26,9 @@ class CompanyResource extends JsonResource
'name' => $this->name,
'debtor' => $this->debtor,
'reference' => $this->reference,
'type' => (int)$this->type,
'business_type' => (int)$this->business_type,
'status' => (int)$this->status,
'type' => (int) $this->type,
'business_type' => (int) $this->business_type,
'status' => (int) $this->status,
'segments' => SegmentResource::collection($companyModule->connections()->first()->segments),
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
'employee' => new UserResource($companyModule->employees()->first()),
+3 -3
View File
@@ -14,15 +14,15 @@ class DocumentResource extends JsonResource
/**
* Transform the resource into an array.
*
* @param Request $request
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request): array
public function toArray($request)
{
return [
'id' => $this->id,
'reference' => $this->reference,
'status' => (int)$this->status,
'status' => (int) $this->status,
'document_type' => $this->document_type,
'owner' => new CompanyResource($this->whenLoaded('owner')),
'files' => $this->when($this->shouldIncludeFiles(false), FileResource::collection($this->files)),
+1 -1
View File
@@ -59,7 +59,7 @@ class Contact extends AbstractModel
protected $dates = ['deleted_at'];
/**
* @return MorphTo
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function owner(): morphTo
{
-3
View File
@@ -11,9 +11,6 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
/**
* @method static whereBetween(string $string, array $array)
*/
class Container extends AbstractModel implements Transportable, Remarkable
{
use HasRelationships;
+1 -1
View File
@@ -71,7 +71,7 @@ class Document extends AbstractModel
protected $dates = ['deleted_at'];
/**
* @return MorphTo
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function owner(): morphTo
{
+1 -2
View File
@@ -8,7 +8,7 @@
],
"license": "MIT",
"require": {
"php": "^7.4",
"php": "^7.3",
"ext-fileinfo": "^7.3",
"ext-json": "*",
"barryvdh/laravel-dompdf": "^0.9.0",
@@ -31,7 +31,6 @@
"tymon/jwt-auth": "^1.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.7",
"barryvdh/laravel-ide-helper": "^2.12",
"codeception/codeception": "^4.2",
"codeception/module-asserts": "^2.0",
@@ -1,34 +1,25 @@
<template>
<transition-component group
enter-class="animate__animated animate__fadeInRight animate__delay-1 animate__faster p-r-30"
leave-class="animate__animated animate__fadeOutLeft animate__faster p-r-30"
style="min-height: 300px;width:100%">
<loading-component style="height: 200px; top: 0;" key="1" color="success"
v-show="$store.getters.isLoading(section)"></loading-component>
<transition-component group enter-class="animate__animated animate__fadeInRight animate__delay-1 animate__faster p-r-30" leave-class="animate__animated animate__fadeOutLeft animate__faster p-r-30" style="min-height: 300px;width:100%">
<loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
<div class="row" key="2" v-show="!$store.getters.isLoading(section)">
<div class="col">
<div class="row">
<div class="col">
<div class="row align-items-center justify-content-center p-t-50 p-b-50"
v-show="!$store.getters.getListData(section).length && !$store.getters.isLoading(section) && emptyListSection">
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-show="!$store.getters.getListData(section).length && !$store.getters.isLoading(section) && emptyListSection">
<div class="col-10">
<div class="row align-items-center justify-content-center hint-text">
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png"
class="w-100 hint-text"/></div>
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
</div>
<div class="row text-center">
<div class="col">
<div class="row m-t-20">
<div class="col">
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing
To Show Here</p>
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here</p>
</div>
</div>
<div class="row m-t-5 align-items-center justify-content-center hide">
<div class="col">
<small class="fs-9 muted all-caps font-lato"
style="letter-spacing: 2px">There is no results found, Try
adjusting your filters to find what you are looking for.</small>
<small class="fs-9 muted all-caps font-lato" style="letter-spacing: 2px">There is no results found, Try adjusting your filters to find what you are looking for.</small>
</div>
</div>
</div>
@@ -38,11 +29,8 @@
<div class="row">
<div class="col">
<div class="list disable-text-selection" data-check-all="checkAll">
<div class="row"
v-for="group in Math.ceil($store.getters.getListData(section).length / columns)">
<div class="col-12" :class="'col-md-'+(12/columns)"
v-for="item in $store.getters.getListData(section).slice((group - 1) * columns, group * columns)"
v-bind:key="item.id" :data="item">
<div class="row" v-for="group in Math.ceil($store.getters.getListData(section).length / columns)">
<div class="col-12" :class="'col-md-'+(12/columns)" v-for="item in $store.getters.getListData(section).slice((group - 1) * columns, group * columns)" v-bind:key="item.id" :data="item">
<slot name="list" :data="item"></slot>
</div>
</div>
@@ -51,8 +39,7 @@
</div>
<div class="row">
<div class="col">
<pagination-component :section="section" class="mb-5"
ref="pagination"></pagination-component>
<pagination-component :section="section" class="mb-5" ref="pagination"></pagination-component>
</div>
</div>
</div>
@@ -63,68 +50,66 @@
</template>
<script>
export default {
props: {
section: {
type: String,
required: true
},
endpoint: {
type: String,
required: true
},
options: {
default() {
return {}
export default {
props: {
section:{
type: String,
required: true
},
endpoint: {
type: String,
required: true
},
options: {
default () {
return {}
}
},
emptyListSection: {
type: Boolean,
default: true
},
columns: {
type: Number,
validator: (prop) => [1, 2, 3, 4, 6, 12].includes(prop),
default: 1
}
},
emptyListSection: {
type: Boolean,
default: true
},
columns: {
type: Number,
validator: (prop) => [1, 2, 3, 4, 6, 12].includes(prop),
default: 1
}
},
data() {
return {
filters: this.options
}
},
created() {
this.setDecoratorDefault();
this.$store.dispatch('updateListQueue', {'name': this.section, 'page': 1, 'filters': this.filters});
},
computed: {
pendingList() {
return this.$store.getters.isInCompleteQueue(this.section);
}
},
watch: {
pendingList(inComplete) {
if (inComplete) {
this.fetchList();
data(){
return {
filters: this.options
}
}
},
methods: {
fetchList() {
let listDecorators = this.$store.getters.getListDetails(this.section);
let endpoint = this.endpoint + '?page=' + listDecorators.page + '&filters=' + JSON.stringify(listDecorators.filters);
console.log(endpoint)
this.submit(this.endpoint + '?page=' + listDecorators.page + '&filters=' + JSON.stringify(listDecorators.filters), 'get', this.section, false, false)
},
updateFilters(filters) {
this.filters = filters;
created(){
this.setDecoratorDefault();
this.submit(this.endpoint + '?page=1&filters=' + JSON.stringify(this.filters), 'get', this.section, false, false)
this.$store.dispatch('updateListQueue', {'name': this.section, 'page': 1, 'filters': this.filters});
},
successHandler(response) {
this.$store.dispatch('completeList', {'name': this.section, 'data': response.payload.data});
this.$refs.pagination.makePagination(response.payload.meta, response.payload.links);
computed: {
pendingList () {
return this.$store.getters.isInCompleteQueue(this.section);
}
},
watch: {
pendingList(inComplete){
if(inComplete){
this.fetchList();
}
}
},
methods: {
fetchList(){
let listDecorators = this.$store.getters.getListDetails(this.section);
this.submit(this.endpoint + '?page=' + listDecorators.page + '&filters=' + JSON.stringify(listDecorators.filters), 'get', this.section, false, false)
},
updateFilters(filters){
this.filters = filters;
this.setDecoratorDefault();
this.submit(this.endpoint + '?page=1&filters=' + JSON.stringify(this.filters), 'get', this.section, false, false)
},
successHandler(response){
this.$store.dispatch('completeList', {'name': this.section, 'data': response.payload.data});
this.$refs.pagination.makePagination(response.payload.meta, response.payload.links);
},
}
}
}
</script>
+154 -153
View File
@@ -73,7 +73,7 @@ Route::domain('hywave.izyim.com')->group(function () {
});
});
Route::group(['prefix' => '/last_mile_delivery', 'as' => 'last_mile_delivery.'], function () {
Route::group(['prefix'=> '/last_mile_delivery', 'as' => 'last_mile_delivery.'], function () {
Route::get('/', function () {
return view('pages.accounts.signup');
})->name('login');
@@ -86,7 +86,7 @@ Route::group(['prefix' => '/last_mile_delivery', 'as' => 'last_mile_delivery.'],
});
Route::group(['prefix' => '/air_shipment', 'as' => 'air_shipment.'], function () {
Route::group(['prefix'=> '/air_shipment', 'as' => 'air_shipment.'], function () {
// Route::get('/', function () {
// return view('pages.accounts.signup');
// })->name('login');
@@ -189,7 +189,7 @@ Route::get('/customer/{marking}/payment-and-billing', function ($marking) {
return view('pages.customers.paymentsBilling', ['company_module_id' => $company_module_id]);
})->name('customer.payment-and-billing');
Route::get('/orders/refresh', function (Request $request) {
Route::get('/orders/refresh', function(Request $request){
$packingLists = PackingList::where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->has('containers')->get();
dd($packingLists);
$packingLists->each(function (PackingList $packingList) {
@@ -204,7 +204,7 @@ Route::get('/orders/refresh', function (Request $request) {
})->name('orders.refresh');
Route::get('/containers/refresh', function () {
Route::get('/containers/refresh', function(){
dd((App()->make(FetchLoadedContainersFromVTPortalProcessor::class))->execute());
// FetchLoadedContainersFromVTPortalJob::dispatch();
@@ -214,7 +214,7 @@ Route::get('/containers/refresh', function () {
})->name('containers.refresh');
Route::get('/deliveries/refresh', function () {
Route::get('/deliveries/refresh', function(){
FetchDeliveryListFromVTPortalJob::dispatch();
@@ -237,37 +237,37 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () {
});
Route::get('/yiwu', function () {
$orders = Order::whereHas('OrderRoles', function ($query) {
$orders = Order::whereHas('OrderRoles', function($query){
return $query->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->where('company_module_id', 2358);
})->get();
foreach ($orders as $order) {
echo '<a target="_blank" href="' . route('order.show', $order->reference) . '">' . $order->reference . ' - ' . $order->created_at . '</a><br>';
foreach ($orders as $order){
echo '<a target="_blank" href="'.route('order.show', $order->reference).'">'. $order->reference.' - '.$order->created_at.'</a><br>';
}
});
Route::get('/guangzhou', function () {
$orders = Order::whereHas('OrderRoles', function ($query) {
$orders = Order::whereHas('OrderRoles', function($query){
return $query->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->where('company_module_id', 3);
})->whereHas('addresses', function ($query) {
})->whereHas('addresses', function($query){
return $query->where('status', ApprovalStatus::APPROVED)->whereIn('state_id', [5, 13, 14]);
})->get();
foreach ($orders as $order) {
echo '<a target="_blank" href="' . route('order.show', $order->reference) . '">' . $order->reference . ' - ' . $order->created_at . '</a><br>';
foreach ($orders as $order){
echo '<a target="_blank" href="'.route('order.show', $order->reference).'">'. $order->reference.' - '.$order->created_at.'</a><br>';
}
});
Route::get('/debug', function () {
Route::get('/debug', function (){
$orders = Order::all();
$issues = [];
foreach ($orders as $order) {
foreach ($orders as $order){
$received = $order->parcels()->warehouseReceiveList()->sum('quantity');
$shipping = $order->parcels()->shippingList()->sum('quantity');
if ($received < $shipping) {
if( $received < $shipping){
$issues[] = [
'order' => $order->reference,
'received' => $received,
@@ -280,23 +280,23 @@ Route::get('/debug', function () {
});
Route::group(['prefix' => 'yd', 'as' => 'yd.'], function () {
Route::get('/packingLists', function (Request $request) {
$start = $request->input('start_date') ? Carbon::parse($request->input('start_date')) : null;
$end = $request->input('end_date') ? Carbon::parse($request->input('end_date')) : null;
Route::get('/packingLists', function (Request $request){
$start = $request->input('start_date') ? Carbon::parse($request->input('start_date')): null;
$end = $request->input('end_date') ? Carbon::parse($request->input('end_date')): null;
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
});
Route::get('/containers', function () {
Route::get('/containers', function (){
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
});
Route::get('/deliveries', function () {
Route::get('/deliveries', function (){
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
});
});
Route::get('/yd', function (Request $request) {
Route::get('/yd', function (Request $request){
// $start = $request->input('start_date') ? Carbon::parse($request->input('start_date')): null;
// $end = $request->input('end_date') ? Carbon::parse($request->input('end_date')): null;
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute($start, $end);
@@ -307,33 +307,33 @@ Route::get('/yd', function (Request $request) {
// (App()->make(FetchPackingListFromVTPortalProcessor::class))->execute();
})->name('yd.refresh');
Route::get('/container/{reference}/refresh/', function (string $reference) {
Route::get('/container/{reference}/refresh/', function (string $reference){
$container = Container::where('reference', $reference)->first();
$supplier = in_array($container->owner_id, [3, 4]) ? 'VT' : 'YD';
$arrivalDates = PackingList::whereIn('reference', $container->packingLists->pluck('reference'))->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->get()->map(function ($packingList) {
$arrivalDates = PackingList::whereIn('reference', $container->packingLists->pluck('reference'))->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->get()->map(function($packingList){
return $packingList->transports()->first()->drop_date;
})->sortBy(function ($date) {
})->sortBy(function($date){
return $date;
});
$startDate = $arrivalDates->first()->subDay()->format('d-m-Y');
$endDate = $arrivalDates->last()->addDay()->format('d-m-Y');
if ($supplier === 'VT') {
if($supplier === 'VT'){
return (App()->make(FetchLoadedContainersFromVTPortalProcessor::class))->execute(Carbon::parse($endDate), Carbon::parse($endDate)->addDays(5));
}
if ($supplier === 'YD') {
return redirect(route('yd.refresh') . '?start_date=' . $startDate . '&end_date=' . $endDate);
if($supplier === 'YD'){
return redirect(route('yd.refresh').'?start_date='.$startDate.'&end_date='.$endDate);
}
})->name('container.refresh');
Route::get('/min_cbm', function () {
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orders', function ($query) {
return $query->whereHas('packingLists')->whereDoesntHave('packingLists', function ($query) {
return $query->whereHas('packages', function ($query) {
Route::get('/min_cbm', function (){
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orders', function ($query){
return $query->whereHas('packingLists')->whereDoesntHave('packingLists', function($query){
return $query->whereHas('packages', function($query){
return $query->selectRaw('sum((width/100) * (height/100) * (length/100) * quantity) as cbm')->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', '!=', 5)->having('cbm', '>', 0.3);
});
});
@@ -342,7 +342,7 @@ Route::get('/min_cbm', function () {
$i = 0;
foreach ($companies as $company) {
$marking = $company->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
echo '<a href="' . route('customer.profile', $marking) . '" target="_blank">' . $i++ . '. ' . $marking . '</a><br>';
echo '<a href="'.route('customer.profile', $marking).'" target="_blank">'.$i++.'. '.$marking.'</a><br>';
}
});
@@ -381,8 +381,8 @@ Route::get('/customer/summary/monthly', function () {
$marking = '769SMC';
$connection = CompanyConnection::where('invitee_reference', $marking)->first();
$companyModuleId = $connection->invitee->id;
foreach ($containers as $container) {
$packingLists = $container->packingLists()->get()->filter(function ($packingList) use ($companyModuleId) {
foreach ($containers as $container){
$packingLists = $container->packingLists()->get()->filter(function ($packingList) use ($companyModuleId){
return $packingList->owner->company_module_id === $companyModuleId;
});
@@ -400,22 +400,22 @@ Route::get('/customer/summary/monthly', function () {
<th>W (cm)</th>
<th>CBM</th>
</tr>';
foreach ($packingLists as $packingList) {
if ($packingList->packingLists->first()) {
foreach ($packingLists as $packingList){
if($packingList->packingLists->first()){
$packingList = $packingList->packingLists->first();
}
$packages = $packingList->packages;
foreach ($packages as $package) {
foreach ($packages as $package){
echo '<tr>
<td>' . $container->loading_date->format('d-m-Y') . '</td>
<td>MS/CIEF/769SMC/' . $packingList->owner->owner->reference . '</td>
<td>' . $container->reference . '</td>
<td>' . $package->description . '</td>
<td>' . $package->quantity . '</td>
<td>' . $package->length . '</td>
<td>' . $package->height . '</td>
<td>' . $package->width . '</td>
<td>' . ((($package->length / 100) * ($package->height / 100) * ($package->width / 100)) * $package->quantity) . '</td>
<td>'.$container->loading_date->format('d-m-Y').'</td>
<td>MS/CIEF/769SMC/'.$packingList->owner->owner->reference.'</td>
<td>'.$container->reference.'</td>
<td>'.$package->description.'</td>
<td>'.$package->quantity.'</td>
<td>'.$package->length.'</td>
<td>'.$package->height.'</td>
<td>'.$package->width.'</td>
<td>'.((($package->length / 100) * ($package->height / 100) * ($package->width / 100)) * $package->quantity).'</td>
</tr>';
}
}
@@ -442,7 +442,7 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
echo '<h4>List of customers active between <span style="color: green; font-weight: bold">' . Carbon::parse($active_start)->format('d/m/Y') . ' - ' . Carbon::parse($active_end)->format('d/m/Y') . '</span> & inactive between <span style="color: red; font-weight: bold">' . Carbon::parse($inactive_start)->format('d/m/Y') . ' - ' . Carbon::parse($inactive_end)->format('d/m/Y') . '</span></h4>';
echo '<h4>List of customers active between <span style="color: green; font-weight: bold">'. Carbon::parse($active_start)->format('d/m/Y'). ' - '. Carbon::parse($active_end)->format('d/m/Y').'</span> & inactive between <span style="color: red; font-weight: bold">'. Carbon::parse($inactive_start)->format('d/m/Y'). ' - '. Carbon::parse($inactive_end)->format('d/m/Y').'</span></h4>';
echo '<table>
<tr>
<th>#</th>
@@ -450,25 +450,25 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina
<th>Number of Orders</th>
<th>CBM</th>
</tr>';
foreach ($companies as $key => $company) {
foreach ($companies as $key => $company){
$connection = $company->inviters()->withPivot('invitee_reference')->first();
$marking = $connection ? $connection->pivot->invitee_reference : '';
$marking = $connection ? $connection->pivot->invitee_reference:'';
$packingList = collect();
$totalCbm = 0;
if ($with_cbm) {
if($with_cbm){
$packingList = $company->orderPackingLists()->where('packing_lists.type', PackingListType::SHIPPING_PACKING_LIST)->get();
$totalCbm = $packingList->flatMap(function ($packingList) {
return $packingList->packages;
})->sum(function ($package) {
return (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) * $package->quantity;
})->sum(function($package){
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
});
}
echo '<tr>
<td>' . $key . '</td>
<td><a href="' . route('customer.profile', $marking) . '" target="_blank">' . $marking . '</a></td>
<td>' . $packingList->count() . '</td>
<td>' . $totalCbm . '</td>
<td>'.$key.'</td>
<td><a href="'.route('customer.profile', $marking).'" target="_blank">'.$marking.'</a></td>
<td>'. $packingList->count() .'</td>
<td>'. $totalCbm .'</td>
</tr>';
}
echo '</table>';
@@ -486,39 +486,39 @@ Route::get('/payment-and-billing', function () {
})->name('admin.payment-and-billing');
Route::get('/notifications/list', 'Notifications\ListNotificationsController@list')->name('notifications.list');
Route::get('billplz/bills/{bill_no}', function ($bill_no) {
return redirect(env('BILLPLZ_BASE_URL') . '/bills/' . $bill_no);
})->name('billplz.bill');
Route::get('billplz/bills/{bill_no}', function($bill_no){
return redirect(env('BILLPLZ_BASE_URL').'/bills/'.$bill_no);
})->name('billplz.bill');
Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor')->name('newDebtor.export');
Route::get('/export/payment-transactions/{section}/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export');
Route::get('/delayed_container/customers', function () {
$containers = Container::whereHas('transports', function ($query) {
return $query->whereHas('Schedules', function ($query) {
Route::get('/delayed_container/customers', function(){
$containers = Container::whereHas('transports', function($query){
return $query->whereHas('Schedules', function($query){
return $query->where('etd', '>', Carbon::parse('15-10-2022'));
});
})->get();
$orders = $containers->map(function ($container) {
$orders = $containers->map(function($container){
return $container->orders;
})->flatten()->unique(function ($order) {
})->flatten()->unique(function($order){
return $order->company_module_id;
});
$companies = CompanyModule::whereIn('id', $orders->pluck('company_module_id'))->get();
foreach ($companies as $company) {
foreach ($companies as $company){
$marking = $company->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
echo '<a target="_blank" href="' . route('customer.profile', $marking) . '">' . $marking . '</a><br>';
echo '<a target="_blank" href="'.route('customer.profile', $marking).'">'.$marking.'</a><br>';
}
});
Route::get('/container/billing/{month}/{year}', function ($month, $year) {
$containers = Container::whereDate('loading_date', '>=', Carbon::parse('01-' . $month . '-' . $year))->whereDate('loading_date', '<', Carbon::parse('01-' . $month . '-' . $year)->addMonth())->get();
Route::get('/container/billing/{month}/{year}', function($month, $year){
$containers = Container::whereDate('loading_date', '>=', Carbon::parse('01-'.$month.'-'.$year))->whereDate('loading_date', '<', Carbon::parse('01-'.$month.'-'.$year)->addMonth())->get();
$totalBillable = 0;
$billed = 0;
@@ -536,7 +536,7 @@ Route::get('/container/billing/{month}/{year}', function ($month, $year) {
$outstationStates = [8, 3, 16, 10];
foreach ($containers as $container) {
foreach($containers as $container) {
$containerTotalBillable = 0;
$containerBilled = 0;
$containerTotalBilled = 0;
@@ -547,7 +547,7 @@ Route::get('/container/billing/{month}/{year}', function ($month, $year) {
$totalBillable += count($packingLists);
$containerTotalBillable += count($packingLists);
echo '<h3>' . $container->reference . ' (' . $container->loading_date->format('d-m-Y') . ')</h3>';
echo '<h3>'.$container->reference.' ('.$container->loading_date->format('d-m-Y').')</h3>';
foreach ($packingLists as $packingList) {
$invoice = $packingList->transactions()
@@ -556,7 +556,7 @@ Route::get('/container/billing/{month}/{year}', function ($month, $year) {
$warehouseList = PackingList::where('reference', $packingList->reference)->where('type', 1)->first();
if ($warehouseList) {
if($warehouseList){
$packing_list_drop_date = $warehouseList->transports->first()->drop_date;
} else {
echo '<------------- can\'t find arrival date -------------->';
@@ -566,30 +566,30 @@ Route::get('/container/billing/{month}/{year}', function ($month, $year) {
$address = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
$cbm = round($packingList->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function ($package) {
return ($package->width / 100) * ($package->height / 100) * ($package->length / 100) * ($package->quantity);
$cbm = round($packingList->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
}), 2);
$over_weight_cbm = round($packingList->packages->where('type', PackageType::OVER_WEIGHT)->sum(function ($package) {
return ($package->width / 100) * ($package->height / 100) * ($package->length / 100) * ($package->quantity);
$over_weight_cbm = round($packingList->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
}), 2);
$price = $basePrice;
if ($warehouseId === 2358) {
if($warehouseId === 2358){
$price += $yiwuCost;
if ($packing_list_drop_date >= Carbon::parse('19-9-2022')) {
if($packing_list_drop_date >= Carbon::parse('19-9-2022')){
$price += $yiwuDiscount;
}
} else {
if ($cbm >= 2 && in_array($address->state_id, [4, 15])) {
if($cbm >= 2 && in_array($address->state_id, [4, 15])){
$price += $bigParcelDiscount;
}
if ($packing_list_drop_date >= Carbon::parse('19-9-2022')) {
if($packing_list_drop_date >= Carbon::parse('19-9-2022')){
$price += $discount;
}
}
if (in_array($address->state_id, $outstationStates)) {
if(in_array($address->state_id,$outstationStates)) {
$price += 50;
}
@@ -598,14 +598,14 @@ Route::get('/container/billing/{month}/{year}', function ($month, $year) {
$containerCost += $cost;
if (in_array($address->state_id, [13, 14])) {
if(in_array($address->state_id, [13, 14])) {
echo 'East Malaysia - ';
}
echo 'estimated cost: [QTY: ' . ($cbm + $over_weight_cbm) . ' | Unit Price: ' . $price . ' | Total: ' . $cost . ']';
echo 'estimated cost: [QTY: '.($cbm + $over_weight_cbm).' | Unit Price: '.$price.' | Total: '.$cost.']';
echo '<br>';
if (!$invoice) {
echo '<p style="color: red"><a href="' . route('order.show', $order->reference) . '" target="_blank">' . $packingList->reference . '</a> Warning: no billing</p>';
if(!$invoice) {
echo '<p style="color: red"><a href="'.route('order.show', $order->reference).'" target="_blank">'.$packingList->reference .'</a> Warning: no billing</p>';
continue;
}
@@ -622,65 +622,65 @@ Route::get('/container/billing/{month}/{year}', function ($month, $year) {
$totalPaid += $payments->sum('amount');
$containerTotalPaid += $payments->sum('amount');
echo '<span style="color: ' . (($invoice->amount - $payments->sum('amount')) < 0.01 ? 'green' : 'red') . '"><p style="color: red"><a href="' . route('order.show', $order->reference) . '" target="_blank">' . $packingList->reference . '</a> | Amount: ' . $invoice->amount . ' | Paid: ' . $payments->sum('amount') . ' | Invoice Date: ' . $invoice->created_at->format('d-m-Y') . (($invoice->amount - $payments->sum('amount')) < 0.01 ? '' : '(' . $invoice->created_at->diffForHumans() . ')') . '</span>';
echo '<span style="color: '.(($invoice->amount - $payments->sum('amount')) < 0.01 ? 'green' : 'red').'"><p style="color: red"><a href="'.route('order.show', $order->reference).'" target="_blank">'.$packingList->reference .'</a> | Amount: '.$invoice->amount.' | Paid: '.$payments->sum('amount').' | Invoice Date: '.$invoice->created_at->format('d-m-Y'). (($invoice->amount - $payments->sum('amount')) < 0.01 ? '' : '('.$invoice->created_at->diffForHumans().')').'</span>';
echo '<br><br>';
}
echo '<h4>Container Invoices: ' . $containerBilled . '/' . $containerTotalBillable . '</h4>';
echo '<h4>Billed Total: ' . $containerTotalBilled . '</h4>';
echo '<h4>Total Paid: ' . $containerTotalPaid . '</h4>';
echo '<h4>Outstanding: ' . ($totalBilled - $containerTotalPaid) . '</h4>';
echo '<h4>Estimated Cost: ' . $containerCost . '</h4>';
echo '<h4>Container Invoices: '.$containerBilled.'/'.$containerTotalBillable.'</h4>';
echo '<h4>Billed Total: '.$containerTotalBilled.'</h4>';
echo '<h4>Total Paid: '.$containerTotalPaid.'</h4>';
echo '<h4>Outstanding: '.($totalBilled - $containerTotalPaid).'</h4>';
echo '<h4>Estimated Cost: '.$containerCost.'</h4>';
echo '<br><br><br>';
}
echo '<h2>Total Invoices: ' . $billed . '/' . $totalBillable . '</h2>';
echo '<h2>Billed Total: ' . $totalBilled . '</h2>';
echo '<h2>Total Paid: ' . $totalPaid . '</h2>';
echo '<h2>Outstanding: ' . ($totalBilled - $totalPaid) . '</h2>';
echo '<h2>Total Invoices: '.$billed.'/'.$totalBillable.'</h2>';
echo '<h2>Billed Total: '.$totalBilled.'</h2>';
echo '<h2>Total Paid: '.$totalPaid.'</h2>';
echo '<h2>Outstanding: '.($totalBilled - $totalPaid).'</h2>';
});
Route::get('/yd/fix', function () {
Route::get('/yd/fix', function(){
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED)->where('claimant_id', 2307)->get();
$i = 0;
echo count($packingLists) . '<br><br>';
foreach ($packingLists as $packingList) {
echo count($packingLists).'<br><br>';
foreach ($packingLists as $packingList){
try {
(App()->make(UpdateDoFromYDPortalProcessor::class))->execute($packingList);
echo 'success' . '<br>';
} catch (Exception $exception) {
echo '<span style="color:red;">' . $packingList->reference . '</span>';
echo 'success'.'<br>';
} catch (Exception $exception){
echo '<span style="color:red;">'.$packingList->reference.'</span>';
}
}
});
Route::get('/billplz/fix', function () {
Route::get('/billplz/fix', function(){
$payments = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->get();
echo '<h3>fixed orders</h3>';
foreach ($payments as $payment) {
$response = Http::withBasicAuth(config('billplz.api_key') . ':', '')->get(config('billplz.base_url') . '/api/v3/bills/' . $payment->payment_reference);
foreach ($payments as $payment){
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$payment->payment_reference);
if ($response->successful()) {
if($response->successful()){
$data = $response->json();
$invoice = $payment->owner;
if (!$invoice) {
if(!$invoice){
continue;
}
$packingList = $invoice->owner;
$order = $packingList->owner;
$order = $packingList->owner;
$orderNumber = $order->reference;
if (!$data['paid'] && $payment->status === ApprovalStatus::APPROVED) {
echo '<br><span style="color: red">Fraude: <a href="' . route('order.show', $orderNumber) . '" target="_blank">' . $orderNumber . '</a></span><br>';
if(!$data['paid'] && $payment->status === ApprovalStatus::APPROVED) {
echo '<br><span style="color: red">Fraude: <a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a></span><br>';
continue;
}
if ($data['paid']) {
if ($payment->status !== ApprovalStatus::APPROVED) {
echo '<a href="' . route('order.show', $orderNumber) . '" target="_blank">' . $orderNumber . '</a><br>';
if($data['paid']){
if($payment->status !== ApprovalStatus::APPROVED){
echo '<a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a><br>';
}
$payment->status = ApprovalStatus::APPROVED;
$payment->save();
@@ -689,30 +689,30 @@ Route::get('/billplz/fix', function () {
$invoice->save();
$packingList = $payment->owner->owner;
if (app()->environment('production')) {
if(app()->environment('production')){
try {
(App()->make(UpdateDoFromVTPortalProcessor::class))->execute($packingList);
(App()->make(UpdateDoFromYDPortalProcessor::class))->execute($packingList);
} catch (Exception $exception) {
echo '<br><span style="color: red">Malformed Address: <a href="' . route('order.show', $orderNumber) . '" target="_blank">' . $orderNumber . '</a></span><br>';
} catch (Exception $exception){
echo '<br><span style="color: red">Malformed Address: <a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a></span><br>';
}
}
}
} else {
echo "billplz error";
}else{
echo "billplz error";
}
}
});
Route::get('/invoices/fix/{company_module_id}', function ($company_module_id) {
Route::get('/invoices/fix/{company_module_id}', function($company_module_id) {
$orders = Order::whereIn('company_module_id', json_decode($company_module_id))->get();
foreach ($orders as $order) {
foreach ($orders as $order){
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
foreach ($invoices as $invoice) {
foreach ($invoices as $invoice){
$invoice->documents()->delete();
@@ -720,7 +720,7 @@ Route::get('/invoices/fix/{company_module_id}', function ($company_module_id) {
$document_object = new DocumentObject(
DocumentType::SHIPPING_INVOICE,
[chunk_split('data:application/pdf;base64,' . base64_encode($transaction_invoice_pdf->output()))],
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
'',
ApprovalStatus::COMPLETED,
'shipping_invoice'
@@ -737,7 +737,7 @@ Route::get('/invoices/fix/{company_module_id}', function ($company_module_id) {
});
Route::get('/invoices/combine/{ids}', function ($ids) {
Route::get('/invoices/combine/{ids}', function($ids){
$ids = json_decode($ids);
@@ -775,7 +775,7 @@ Route::get('/invoices/combine/{ids}', function ($ids) {
// }
// })->name('generate.invoices');
Route::get('/invoices/approve', function (Request $request) {
Route::get('/invoices/approve', function(Request $request){
// whereDoesntHave
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::PENDING_SUBMISSION)->get();
@@ -783,8 +783,8 @@ Route::get('/invoices/approve', function (Request $request) {
$packingList = $invoice->owner;
$order = $packingList->owner;
if ($request->input('exclude')) {
if (in_array($order->reference, json_decode($request->input('exclude')))) {
if ($request->input('exclude')){
if(in_array($order->reference, json_decode($request->input('exclude')))){
continue;
}
}
@@ -793,7 +793,7 @@ Route::get('/invoices/approve', function (Request $request) {
(App()->make(ApproveShippingInvoiceTransactionProcessor::class))->execute($packingList);
echo '<span style="color: green;">Invoice Approved...</span><br>';
} catch (Exception $exception) {
} catch (Exception $exception){
echo '<span style="color: red;">failed to approve...</span><br>';
}
@@ -802,10 +802,10 @@ Route::get('/invoices/approve', function (Request $request) {
})->name('invoices.approve');
Route::get('/invoices/show-duplicated', function (Request $request) {
Route::get('/invoices/show-duplicated', function(Request $request){
$transactionWithMultipleInvoice = DB::table('transactions')
->where('type', TransactionType::SHIPPING_INVOICE)
->where('status', '!=', ApprovalStatus::EXPIRED)
->where('status', '!=' , ApprovalStatus::EXPIRED)
->where('deleted_at', null)
->select('owner_id', DB::raw('count(*) as count'))
->groupBy('owner_id')
@@ -816,7 +816,7 @@ Route::get('/invoices/show-duplicated', function (Request $request) {
$duplicatedOrderId = [];
$duplicatedOrderArray = [];
foreach ($transactionWithMultipleInvoice as $invoice) {
foreach($transactionWithMultipleInvoice as $invoice) {
$duplicatedOrderId[] = $invoice->owner_id;
$duplicatedOrderArray[$invoice->owner_id] = $invoice->count;
}
@@ -832,23 +832,23 @@ Route::get('/invoices/show-duplicated', function (Request $request) {
echo "<td style='border:1px solid'>Count</td>";
echo "</tr>";
foreach ($duplicatedInvoice as $invoice) {
foreach($duplicatedInvoice as $invoice) {
$order = $invoice->owner->owner;
echo "<tr>";
echo '<td style="border:1px solid"><a target="_blank" href="' . route('order.show', $order->reference) . '">' . $order->reference . ' - </a>' . $order->created_at . '</td>';
echo "<td style='border:1px solid'>" . ApprovalStatus::APPROVAL_STATUS_ID[$invoice->status] . "</td>";
echo '<td style="border:1px solid"><a target="_blank" href="'.route('order.show', $order->reference).'">'. $order->reference.' - </a>' . $order->created_at . '</td>';
echo "<td style='border:1px solid'>".ApprovalStatus::APPROVAL_STATUS_ID[$invoice->status]."</td>";
echo "<td style='border:1px solid'>$invoice->owner_id</td>";
echo "<td style='border:1px solid'>$invoice->amount</td>";
echo "<td style='border:1px solid'>" . $duplicatedOrderArray[$invoice->owner_id] . "</td>";
echo "<td style='border:1px solid'>".$duplicatedOrderArray[$invoice->owner_id]."</td>";
echo "</tr>";
}
echo '</table>';
});
Route::get('/invoices/delete-duplicated', function (Request $request) {
Route::get('/invoices/delete-duplicated', function(Request $request){
$duplicatedInvoices = DB::table('transactions')
->where('type', TransactionType::SHIPPING_INVOICE)
->where('status', '!=', ApprovalStatus::EXPIRED)
->where('status', '!=' , ApprovalStatus::EXPIRED)
->where('deleted_at', null)
->select('owner_id', DB::raw('count(*) as count'))
->groupBy('owner_id')
@@ -857,7 +857,7 @@ Route::get('/invoices/delete-duplicated', function (Request $request) {
$duplicatedInvoices = Transaction::whereIn('owner_id', $duplicatedInvoices->pluck('owner_id'))->get()->groupBy('owner_id');
foreach ($duplicatedInvoices as $invoice) {
foreach($duplicatedInvoices as $invoice) {
$packingList = $invoice->first()->owner;
$order = $packingList->owner;
@@ -898,12 +898,12 @@ Route::get('/invoices/delete-duplicated', function (Request $request) {
}
});
Route::get('/packing-lists/show-duplicated', function (Request $request) {
Route::get('/packing-lists/show-duplicated', function(Request $request){
$results = PackingList::select('reference', 'type', DB::raw('count(*) as total'))
->groupBy('reference', 'type')
->having('total', '>', 1)
->get()
->toArray();
->groupBy('reference', 'type')
->having('total', '>', 1)
->get()
->toArray();
echo '<table>';
echo "<tr>";
@@ -912,7 +912,7 @@ Route::get('/packing-lists/show-duplicated', function (Request $request) {
echo "<td style='border:1px solid'>count</td>";
echo "</tr>";
foreach ($results as $result) {
foreach($results as $result) {
// dd($result);
echo "<tr>";
echo "<td style='border:1px solid'>" . $result['reference'] . "</td>";
@@ -923,18 +923,18 @@ Route::get('/packing-lists/show-duplicated', function (Request $request) {
echo '</table>';
});
Route::get('/packing-lists/delete-duplicated', function (Request $request) {
Route::get('/packing-lists/delete-duplicated', function(Request $request){
$results = PackingList::select('reference', 'type', DB::raw('count(*) as total'))
->groupBy('reference', 'type')
->having('total', '>', 1)
->get()
->toArray();
foreach ($results as $result) {
foreach($results as $result) {
$duplicatedPackingList = PackingList::where('reference', $result['reference'])->where('type', $result['type'])->orderBy('id', 'desc')->get();
// if packinglist has paid inivoice
$paidPackinglist = PackingList::where('reference', $result['reference'])->where('type', $result['type'])->whereHas('transactions', function ($query) {
$paidPackinglist = PackingList::where('reference', $result['reference'])->where('type', $result['type'])->whereHas('transactions', function($query){
return $query->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::COMPLETED);
})->get();
@@ -967,6 +967,7 @@ Route::get('/wallet/{marking}/details', function ($marking) {
Route::get('/wallet/audit', function (Request $request) {
$wallets = \App\Models\Wallet::all();
$i = 0;
foreach ($wallets as $wallet){
$topups = 0;
@@ -974,20 +975,20 @@ Route::get('/wallet/audit', function (Request $request) {
$payments = 0;
$debit = 0;
foreach ($wallet->transactions as $transaction) {
if (!in_array((int)$transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
if ((int)$transaction->type === TransactionType::TOP_UP) {
$topups += (float)$transaction->amount;
foreach ($wallet->transactions as $transaction){
if(!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
if((int) $transaction->type === TransactionType::TOP_UP) {
$topups += (float) $transaction->amount;
}
if ((int)$transaction->type === TransactionType::CREDIT_NOTE) $credit += (float)$transaction->amount;
if ((int)$transaction->type === TransactionType::PAYMENT) $payments += (float)$transaction->amount;
if ((int)$transaction->type === TransactionType::DEBIT_NOTE) $debit += (float)$transaction->amount;
if((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
if((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
if((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
}
if ((round((float)$wallet->amount - (($topups + $credit) - ($payments + $debit)), 2) == 0) and $wallet->amount > -0.01) continue;
if((round((float) $wallet->amount - (($topups + $credit) - ($payments + $debit)), 2) == 0) AND $wallet->amount > -0.01) continue;
$i++;
echo $i . ". Marking: " . $wallet->owner->connections->first()->invitee_reference . "(" . $wallet->id . ")<br>Current Balance: " . $wallet->amount . "<br>Audit Balance: " . (($topups + $credit) - ($payments + $debit)) . "<br>Difference: " . round((float)$wallet->amount - (($topups + $credit) - ($payments + $debit)), 2) . "<br><br><br>";
echo $i.". Marking: ". $wallet->owner->connections->first()->invitee_reference ."(".$wallet->id.")<br>Current Balance: ". $wallet->amount ."<br>Audit Balance: ". (($topups + $credit) - ($payments + $debit)) ."<br>Difference: ". round((float) $wallet->amount - (($topups + $credit) - ($payments + $debit)), 2) ."<br><br><br>";
}
});