diff --git a/app/Classes/Modules/Documents/ControllersLogic/ListDocumentLogic.php b/app/Classes/Modules/Documents/ControllersLogic/ListDocumentLogic.php index 044c9c2c..e4032566 100644 --- a/app/Classes/Modules/Documents/ControllersLogic/ListDocumentLogic.php +++ b/app/Classes/Modules/Documents/ControllersLogic/ListDocumentLogic.php @@ -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() diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index 12579b8a..38a8cf67 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -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()), diff --git a/app/Http/Resources/DocumentResource.php b/app/Http/Resources/DocumentResource.php index d383948a..27edc1a0 100644 --- a/app/Http/Resources/DocumentResource.php +++ b/app/Http/Resources/DocumentResource.php @@ -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)), diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 5ed1b2db..d36efb09 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -59,7 +59,7 @@ class Contact extends AbstractModel protected $dates = ['deleted_at']; /** - * @return MorphTo + * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ public function owner(): morphTo { diff --git a/app/Models/Container.php b/app/Models/Container.php index 47ea9c88..efe946f9 100644 --- a/app/Models/Container.php +++ b/app/Models/Container.php @@ -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; diff --git a/app/Models/Document.php b/app/Models/Document.php index 38954bb1..b7e561c1 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -71,7 +71,7 @@ class Document extends AbstractModel protected $dates = ['deleted_at']; /** - * @return MorphTo + * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ public function owner(): morphTo { diff --git a/composer.json b/composer.json index 4451a3ea..e2b684e5 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/resources/assets/vue/components/general/elements/ListComponent.vue b/resources/assets/vue/components/general/elements/ListComponent.vue index 7785ecf4..bd1c759c 100644 --- a/resources/assets/vue/components/general/elements/ListComponent.vue +++ b/resources/assets/vue/components/general/elements/ListComponent.vue @@ -1,34 +1,25 @@ diff --git a/routes/web.php b/routes/web.php index b59270f4..324dd3cb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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 '' . $order->reference . ' - ' . $order->created_at . '
'; + foreach ($orders as $order){ + echo ''. $order->reference.' - '.$order->created_at.'
'; } }); 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 '' . $order->reference . ' - ' . $order->created_at . '
'; + foreach ($orders as $order){ + echo ''. $order->reference.' - '.$order->created_at.'
'; } }); -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 '' . $i++ . '. ' . $marking . '
'; + echo ''.$i++.'. '.$marking.'
'; } }); @@ -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 () { W (cm) CBM '; - 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 ' - ' . $container->loading_date->format('d-m-Y') . ' - MS/CIEF/769SMC/' . $packingList->owner->owner->reference . ' - ' . $container->reference . ' - ' . $package->description . ' - ' . $package->quantity . ' - ' . $package->length . ' - ' . $package->height . ' - ' . $package->width . ' - ' . ((($package->length / 100) * ($package->height / 100) * ($package->width / 100)) * $package->quantity) . ' + '.$container->loading_date->format('d-m-Y').' + MS/CIEF/769SMC/'.$packingList->owner->owner->reference.' + '.$container->reference.' + '.$package->description.' + '.$package->quantity.' + '.$package->length.' + '.$package->height.' + '.$package->width.' + '.((($package->length / 100) * ($package->height / 100) * ($package->width / 100)) * $package->quantity).' '; } } @@ -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 '

List of customers active between ' . Carbon::parse($active_start)->format('d/m/Y') . ' - ' . Carbon::parse($active_end)->format('d/m/Y') . ' & inactive between ' . Carbon::parse($inactive_start)->format('d/m/Y') . ' - ' . Carbon::parse($inactive_end)->format('d/m/Y') . '

'; + echo '

List of customers active between '. Carbon::parse($active_start)->format('d/m/Y'). ' - '. Carbon::parse($active_end)->format('d/m/Y').' & inactive between '. Carbon::parse($inactive_start)->format('d/m/Y'). ' - '. Carbon::parse($inactive_end)->format('d/m/Y').'

'; echo ' @@ -450,25 +450,25 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina '; - 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 ' - - - - + + + + '; } echo '
#Number of Orders CBM
' . $key . '' . $marking . '' . $packingList->count() . '' . $totalCbm . ''.$key.''.$marking.''. $packingList->count() .''. $totalCbm .'
'; @@ -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 '' . $marking . '
'; + echo ''.$marking.'
'; } }); -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 '

' . $container->reference . ' (' . $container->loading_date->format('d-m-Y') . ')

'; + echo '

'.$container->reference.' ('.$container->loading_date->format('d-m-Y').')

'; 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 '
'; - if (!$invoice) { - echo '

' . $packingList->reference . ' Warning: no billing

'; + if(!$invoice) { + echo '

'.$packingList->reference .' Warning: no billing

'; continue; } @@ -622,65 +622,65 @@ Route::get('/container/billing/{month}/{year}', function ($month, $year) { $totalPaid += $payments->sum('amount'); $containerTotalPaid += $payments->sum('amount'); - echo '

' . $packingList->reference . ' | 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() . ')') . ''; + echo '

'.$packingList->reference .' | 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().')').''; echo '

'; } - echo '

Container Invoices: ' . $containerBilled . '/' . $containerTotalBillable . '

'; - echo '

Billed Total: ' . $containerTotalBilled . '

'; - echo '

Total Paid: ' . $containerTotalPaid . '

'; - echo '

Outstanding: ' . ($totalBilled - $containerTotalPaid) . '

'; - echo '

Estimated Cost: ' . $containerCost . '

'; + echo '

Container Invoices: '.$containerBilled.'/'.$containerTotalBillable.'

'; + echo '

Billed Total: '.$containerTotalBilled.'

'; + echo '

Total Paid: '.$containerTotalPaid.'

'; + echo '

Outstanding: '.($totalBilled - $containerTotalPaid).'

'; + echo '

Estimated Cost: '.$containerCost.'

'; echo '


'; } - echo '

Total Invoices: ' . $billed . '/' . $totalBillable . '

'; - echo '

Billed Total: ' . $totalBilled . '

'; - echo '

Total Paid: ' . $totalPaid . '

'; - echo '

Outstanding: ' . ($totalBilled - $totalPaid) . '

'; + echo '

Total Invoices: '.$billed.'/'.$totalBillable.'

'; + echo '

Billed Total: '.$totalBilled.'

'; + echo '

Total Paid: '.$totalPaid.'

'; + echo '

Outstanding: '.($totalBilled - $totalPaid).'

'; }); -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) . '

'; - foreach ($packingLists as $packingList) { + echo count($packingLists).'

'; + foreach ($packingLists as $packingList){ try { (App()->make(UpdateDoFromYDPortalProcessor::class))->execute($packingList); - echo 'success' . '
'; - } catch (Exception $exception) { - echo '' . $packingList->reference . ''; + echo 'success'.'
'; + } catch (Exception $exception){ + echo ''.$packingList->reference.''; } } }); -Route::get('/billplz/fix', function () { +Route::get('/billplz/fix', function(){ $payments = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->get(); echo '

fixed orders

'; - 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 '
Fraude: ' . $orderNumber . '
'; + if(!$data['paid'] && $payment->status === ApprovalStatus::APPROVED) { + echo '
Fraude: '.$orderNumber.'
'; continue; } - if ($data['paid']) { - if ($payment->status !== ApprovalStatus::APPROVED) { - echo '' . $orderNumber . '
'; + if($data['paid']){ + if($payment->status !== ApprovalStatus::APPROVED){ + echo ''.$orderNumber.'
'; } $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 '
Malformed Address: ' . $orderNumber . '
'; + } catch (Exception $exception){ + echo '
Malformed Address: '.$orderNumber.'
'; } } } - } 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 'Invoice Approved...
'; - } catch (Exception $exception) { + } catch (Exception $exception){ echo 'failed to approve...
'; } @@ -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 "Count"; echo ""; - foreach ($duplicatedInvoice as $invoice) { + foreach($duplicatedInvoice as $invoice) { $order = $invoice->owner->owner; echo ""; - echo '' . $order->reference . ' - ' . $order->created_at . ''; - echo "" . ApprovalStatus::APPROVAL_STATUS_ID[$invoice->status] . ""; + echo ''. $order->reference.' - ' . $order->created_at . ''; + echo "".ApprovalStatus::APPROVAL_STATUS_ID[$invoice->status].""; echo "$invoice->owner_id"; echo "$invoice->amount"; - echo "" . $duplicatedOrderArray[$invoice->owner_id] . ""; + echo "".$duplicatedOrderArray[$invoice->owner_id].""; echo ""; } echo ''; }); -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 ''; echo ""; @@ -912,7 +912,7 @@ Route::get('/packing-lists/show-duplicated', function (Request $request) { echo ""; echo ""; - foreach ($results as $result) { + foreach($results as $result) { // dd($result); echo ""; echo ""; @@ -923,18 +923,18 @@ Route::get('/packing-lists/show-duplicated', function (Request $request) { echo '
count
" . $result['reference'] . "
'; }); -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 . ")
Current Balance: " . $wallet->amount . "
Audit Balance: " . (($topups + $credit) - ($payments + $debit)) . "
Difference: " . round((float)$wallet->amount - (($topups + $credit) - ($payments + $debit)), 2) . "


"; + echo $i.". Marking: ". $wallet->owner->connections->first()->invitee_reference ."(".$wallet->id.")
Current Balance: ". $wallet->amount ."
Audit Balance: ". (($topups + $credit) - ($payments + $debit)) ."
Difference: ". round((float) $wallet->amount - (($topups + $credit) - ($payments + $debit)), 2) ."


"; } });