From d23b59b8e906ee31228d2cb2b7a8b624202b4a0c Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 8 Sep 2021 16:44:24 +0800 Subject: [PATCH 01/52] payment and billing ui --- .../elements/PaymentsBillingComponents.vue | 131 ++++++++++++++++++ .../pages/templates/paymentsBilling.blade.php | 128 +++++++++++++++++ resources/views/partials/menu.blade.php | 2 +- routes/web.php | 6 +- 4 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue create mode 100644 resources/views/pages/templates/paymentsBilling.blade.php diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue new file mode 100644 index 00000000..86535a80 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue @@ -0,0 +1,131 @@ + + diff --git a/resources/views/pages/templates/paymentsBilling.blade.php b/resources/views/pages/templates/paymentsBilling.blade.php new file mode 100644 index 00000000..f8a7719d --- /dev/null +++ b/resources/views/pages/templates/paymentsBilling.blade.php @@ -0,0 +1,128 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+
+
+
+
+
+
+
+
+ +
+
+
Invoice No
+
+
+
Invoice Date
+
+
+
Status
+
+
+
Amount
+
+ +
+
+
+
+
+ + + +
+
+
+
+
+
+
Payment Summary
+
+
+
+
+
+ +
+
+
+
2 Invoice Selected
+
+
+
+
+
+
+
x1
+
+
+
lorem ipsum
+
+
+
52x62x635 CM
+
+
+
+
+
x1
+
+
+
lorem ipsum
+
+
+
52x62x635 CM
+
+
+
+
+
+
+
+
Shipping Fee
+
+
+
RM 212.15
+
+
+
+
+
Serrvice Fee
+
+
+
RM 41.25
+
+
+
+
+
Discount
+
+
+
RM 0.00
+
+
+
+
+
+
Total Payments
+
+
+
RM 3300.00
+
+
+
+
+
+
+
+
+ +@endsection \ No newline at end of file diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 73f727b9..4a122b0a 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -82,7 +82,7 @@ style=" fill:#000000;">
-
Payments & Billing
+
Payments & Billing
diff --git a/routes/web.php b/routes/web.php index b1370bfe..f2180626 100644 --- a/routes/web.php +++ b/routes/web.php @@ -80,4 +80,8 @@ Route::get('/test', function(){ $address->street_two = (new \App\Classes\Modules\Addresses\Services\CleansOldAddress())->cleanAddress($address->street_two, $address->district, $address->postcode); $address->save(); } -})->name('test'); \ No newline at end of file +})->name('test'); + +Route::get('/payments-and-billing', function () { + return view('pages.templates.paymentsBilling'); +})->name('payments-and-billing'); \ No newline at end of file From c652d8df1adc77375f361d94987840f93365b85a Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 10 Sep 2021 15:58:28 +0800 Subject: [PATCH 02/52] shipping queue ui --- .../elements/shippingQueueComponents.vue | 94 ++++++++++++++ .../pages/templates/shippingQueue.blade.php | 120 ++++++++++++++++++ resources/views/partials/menu.blade.php | 11 ++ routes/web.php | 6 +- 4 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 resources/assets/vue/components/shippingQueue/elements/shippingQueueComponents.vue create mode 100644 resources/views/pages/templates/shippingQueue.blade.php diff --git a/resources/assets/vue/components/shippingQueue/elements/shippingQueueComponents.vue b/resources/assets/vue/components/shippingQueue/elements/shippingQueueComponents.vue new file mode 100644 index 00000000..41c20a1c --- /dev/null +++ b/resources/assets/vue/components/shippingQueue/elements/shippingQueueComponents.vue @@ -0,0 +1,94 @@ + + diff --git a/resources/views/pages/templates/shippingQueue.blade.php b/resources/views/pages/templates/shippingQueue.blade.php new file mode 100644 index 00000000..455d5bb2 --- /dev/null +++ b/resources/views/pages/templates/shippingQueue.blade.php @@ -0,0 +1,120 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+
+
+
+
+

Shipping ID: 05052021-25-0100

+
+
+
+
+
+
+
+
+
Discount Code
+
+
+
+
+
Free 10
+
+
+
Removed
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+

Shipping cost estimation

+
+
+
+
+
+
+
Shipping Cost: RM8400
+
+
+
+
+
SST(6%): RM600
+
+
+
+
+
Discount: RM100
+
+
+
+
+
+
+
+
+
Total Cost:
+
+
+
+
+

RM7300

+
+
+
+
+
+
+
+
+
+
+
+
+

Group my products with same destination

+
+
+
+
+

You will get grouped package at once if possible

+
+
+
+
+
+
+
+
+
+
+
+
+ Checkout +
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 73f727b9..467daf85 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -96,6 +96,17 @@
Tracking
+
+
+ +
+ +
diff --git a/routes/web.php b/routes/web.php index b1370bfe..17b46032 100644 --- a/routes/web.php +++ b/routes/web.php @@ -80,4 +80,8 @@ Route::get('/test', function(){ $address->street_two = (new \App\Classes\Modules\Addresses\Services\CleansOldAddress())->cleanAddress($address->street_two, $address->district, $address->postcode); $address->save(); } -})->name('test'); \ No newline at end of file +})->name('test'); + +Route::get('/shipping-queue', function () { + return view('pages.templates.shippingQueue'); +})->name('shipping-queue'); \ No newline at end of file From 688832445a4bbc808a622e2f638907da17acc482 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 10 Sep 2021 16:41:30 +0800 Subject: [PATCH 03/52] add the route for shipping queue --- routes/web.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routes/web.php b/routes/web.php index 2eb2bcbb..56faa99a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,6 +97,10 @@ Route::get('/containers/refresh', function(){ })->name('containers.refresh'); +Route::get('/shipping-queue', function () { + return view('pages.templates.shippingQueue'); +})->name('shipping-queue'); + Route::get('/deliveries/refresh', function(){ FetchDeliveryListFromVTPortalJob::dispatch(); From b5076a6f9dc88a44009554349164728d33afc074 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Thu, 16 Sep 2021 20:47:33 +0800 Subject: [PATCH 04/52] Excel library, controllers --- .gitignore | 3 +- .../Processors/FetchPackingListProcessor.php | 63 ++++ .../CustomcClearanceLogic.php | 38 ++ .../ControllersLogic/ExportExcelLogic.php | 51 +++ .../CustomcClearanceReportController.php | 17 + composer.json | 1 + config/app.php | 4 +- config/excel.php | 328 ++++++++++++++++++ resources/views/layouts/base_portal.blade.php | 13 +- routes/web.php | 2 + 10 files changed, 517 insertions(+), 3 deletions(-) create mode 100644 app/Classes/Modules/PackingLists/Processors/FetchPackingListProcessor.php create mode 100644 app/Classes/Modules/Reports/ControllersLogic/CustomcClearanceLogic.php create mode 100644 app/Classes/Modules/Reports/ControllersLogic/ExportExcelLogic.php create mode 100644 app/Http/Controllers/Reports/CustomcClearanceReportController.php create mode 100644 config/excel.php diff --git a/.gitignore b/.gitignore index 95d268cf..9b34cbea 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ db/* docker-compose.yml package-lock.json public/* -/public/* \ No newline at end of file +/public/* +storage/framework/laravel-excel/* diff --git a/app/Classes/Modules/PackingLists/Processors/FetchPackingListProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchPackingListProcessor.php new file mode 100644 index 00000000..b128aeed --- /dev/null +++ b/app/Classes/Modules/PackingLists/Processors/FetchPackingListProcessor.php @@ -0,0 +1,63 @@ +listsPackingLists = $listsPackingLists; + } + + /** + * @return array + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function execute(){ + + $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST) + ->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED]) + ->whereDoesntHave('containers', function($query){ + $query->where('status', '=', ApprovalStatus::COMPLETED); + })->orderBy('created_at','desc')->limit(5)->get(); + + $packingListsArray=[]; + foreach($packingLists as $packingList){ + + $address = $packingList->owner->addresses()->first(); + $packingList->fulladdress = $address->street_one.', '.$address->street_two.', '.$address->district->name.', '.$address->post_code.' '.$address->state->name.', '.$address->country->name; + + $container = $packingList->containers()->first(); + $packingList->container_reference = $container->reference; + $packingList->container_number = $container->container_number; + + $packingListsArray[]=$packingList; + + } + + return $packingListsArray; + + } + + +} diff --git a/app/Classes/Modules/Reports/ControllersLogic/CustomcClearanceLogic.php b/app/Classes/Modules/Reports/ControllersLogic/CustomcClearanceLogic.php new file mode 100644 index 00000000..5557c185 --- /dev/null +++ b/app/Classes/Modules/Reports/ControllersLogic/CustomcClearanceLogic.php @@ -0,0 +1,38 @@ +listsPackingListProcessor = $listsPackingListProcessor; + } + + protected function notification():array { + return []; + } + + public function logic(Request $request) : JsonResponse + { + $packingLists = $this->listsPackingListProcessor->execute(); + $excelExportLogic = new ExportExcelLogic(collect($packingLists)); + $this->excelExportLogic = $excelExportLogic; + + return response()->json(['success' => true]); + } + + public function getExcelCollection(){ + return $this->excelExportLogic; + } +} diff --git a/app/Classes/Modules/Reports/ControllersLogic/ExportExcelLogic.php b/app/Classes/Modules/Reports/ControllersLogic/ExportExcelLogic.php new file mode 100644 index 00000000..ede392b4 --- /dev/null +++ b/app/Classes/Modules/Reports/ControllersLogic/ExportExcelLogic.php @@ -0,0 +1,51 @@ +data=$data; + } + public function collection() + { + return $this->data; + } + public function map($order): array + { + return [ + (string)$order->reference, + (string)$order->container_number, + (string)$order->fulladdress, + (string)$order->created_at, + "ssxxx" + ]; + } + + public function columnFormats(): array + { + return [ + 'A'=>'@', + 'B' => NumberFormat::FORMAT_DATE_DDMMYYYY, + + ]; + } + + public function headings(): array + { + return ["Reference", "Container", "Address", "Created", "Status"]; + } + +} diff --git a/app/Http/Controllers/Reports/CustomcClearanceReportController.php b/app/Http/Controllers/Reports/CustomcClearanceReportController.php new file mode 100644 index 00000000..e7d24ff0 --- /dev/null +++ b/app/Http/Controllers/Reports/CustomcClearanceReportController.php @@ -0,0 +1,17 @@ +logic($request); + return Excel::download( $customClearancelogic->getExcelCollection(), $filename.'.xlsx'); + } +} diff --git a/composer.json b/composer.json index 824d2d3f..56ab4aac 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "intervention/image": "^2.5", "laravel/framework": "^8.40", "laravel/tinker": "^2.5", + "maatwebsite/excel": "^3.1", "rinvex/countries": "^6.1", "spatie/laravel-activitylog": "^3.14", "spatie/laravel-permission": "^4.2", diff --git a/config/app.php b/config/app.php index bad26462..df3e7a90 100644 --- a/config/app.php +++ b/config/app.php @@ -178,7 +178,8 @@ return [ // Third Parties Spatie\Permission\PermissionServiceProvider::class, Barryvdh\DomPDF\ServiceProvider::class, - Meneses\LaravelMpdf\LaravelMpdfServiceProvider::class + Meneses\LaravelMpdf\LaravelMpdfServiceProvider::class, + Maatwebsite\Excel\ExcelServiceProvider::class, ], /* @@ -233,6 +234,7 @@ return [ 'View' => Illuminate\Support\Facades\View::class, 'PDF' => Barryvdh\DomPDF\Facade::class, 'MPDF' => Meneses\LaravelMpdf\Facades\LaravelMpdf::class, + 'Excel' => Maatwebsite\Excel\Facades\Excel::class, ], ]; diff --git a/config/excel.php b/config/excel.php new file mode 100644 index 00000000..c3199b92 --- /dev/null +++ b/config/excel.php @@ -0,0 +1,328 @@ + [ + + /* + |-------------------------------------------------------------------------- + | Chunk size + |-------------------------------------------------------------------------- + | + | When using FromQuery, the query is automatically chunked. + | Here you can specify how big the chunk should be. + | + */ + 'chunk_size' => 1000, + + /* + |-------------------------------------------------------------------------- + | Pre-calculate formulas during export + |-------------------------------------------------------------------------- + */ + 'pre_calculate_formulas' => false, + + /* + |-------------------------------------------------------------------------- + | Enable strict null comparison + |-------------------------------------------------------------------------- + | + | When enabling strict null comparison empty cells ('') will + | be added to the sheet. + */ + 'strict_null_comparison' => false, + + /* + |-------------------------------------------------------------------------- + | CSV Settings + |-------------------------------------------------------------------------- + | + | Configure e.g. delimiter, enclosure and line ending for CSV exports. + | + */ + 'csv' => [ + 'delimiter' => ',', + 'enclosure' => '"', + 'line_ending' => PHP_EOL, + 'use_bom' => false, + 'include_separator_line' => false, + 'excel_compatibility' => false, + ], + + /* + |-------------------------------------------------------------------------- + | Worksheet properties + |-------------------------------------------------------------------------- + | + | Configure e.g. default title, creator, subject,... + | + */ + 'properties' => [ + 'creator' => '', + 'lastModifiedBy' => '', + 'title' => '', + 'description' => '', + 'subject' => '', + 'keywords' => '', + 'category' => '', + 'manager' => '', + 'company' => '', + ], + ], + + 'imports' => [ + + /* + |-------------------------------------------------------------------------- + | Read Only + |-------------------------------------------------------------------------- + | + | When dealing with imports, you might only be interested in the + | data that the sheet exists. By default we ignore all styles, + | however if you want to do some logic based on style data + | you can enable it by setting read_only to false. + | + */ + 'read_only' => true, + + /* + |-------------------------------------------------------------------------- + | Ignore Empty + |-------------------------------------------------------------------------- + | + | When dealing with imports, you might be interested in ignoring + | rows that have null values or empty strings. By default rows + | containing empty strings or empty values are not ignored but can be + | ignored by enabling the setting ignore_empty to true. + | + */ + 'ignore_empty' => false, + + /* + |-------------------------------------------------------------------------- + | Heading Row Formatter + |-------------------------------------------------------------------------- + | + | Configure the heading row formatter. + | Available options: none|slug|custom + | + */ + 'heading_row' => [ + 'formatter' => 'slug', + ], + + /* + |-------------------------------------------------------------------------- + | CSV Settings + |-------------------------------------------------------------------------- + | + | Configure e.g. delimiter, enclosure and line ending for CSV imports. + | + */ + 'csv' => [ + 'delimiter' => ',', + 'enclosure' => '"', + 'escape_character' => '\\', + 'contiguous' => false, + 'input_encoding' => 'UTF-8', + ], + + /* + |-------------------------------------------------------------------------- + | Worksheet properties + |-------------------------------------------------------------------------- + | + | Configure e.g. default title, creator, subject,... + | + */ + 'properties' => [ + 'creator' => '', + 'lastModifiedBy' => '', + 'title' => '', + 'description' => '', + 'subject' => '', + 'keywords' => '', + 'category' => '', + 'manager' => '', + 'company' => '', + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Extension detector + |-------------------------------------------------------------------------- + | + | Configure here which writer/reader type should be used when the package + | needs to guess the correct type based on the extension alone. + | + */ + 'extension_detector' => [ + 'xlsx' => Excel::XLSX, + 'xlsm' => Excel::XLSX, + 'xltx' => Excel::XLSX, + 'xltm' => Excel::XLSX, + 'xls' => Excel::XLS, + 'xlt' => Excel::XLS, + 'ods' => Excel::ODS, + 'ots' => Excel::ODS, + 'slk' => Excel::SLK, + 'xml' => Excel::XML, + 'gnumeric' => Excel::GNUMERIC, + 'htm' => Excel::HTML, + 'html' => Excel::HTML, + 'csv' => Excel::CSV, + 'tsv' => Excel::TSV, + + /* + |-------------------------------------------------------------------------- + | PDF Extension + |-------------------------------------------------------------------------- + | + | Configure here which Pdf driver should be used by default. + | Available options: Excel::MPDF | Excel::TCPDF | Excel::DOMPDF + | + */ + 'pdf' => Excel::DOMPDF, + ], + + /* + |-------------------------------------------------------------------------- + | Value Binder + |-------------------------------------------------------------------------- + | + | PhpSpreadsheet offers a way to hook into the process of a value being + | written to a cell. In there some assumptions are made on how the + | value should be formatted. If you want to change those defaults, + | you can implement your own default value binder. + | + | Possible value binders: + | + | [x] Maatwebsite\Excel\DefaultValueBinder::class + | [x] PhpOffice\PhpSpreadsheet\Cell\StringValueBinder::class + | [x] PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class + | + */ + 'value_binder' => [ + 'default' => Maatwebsite\Excel\DefaultValueBinder::class, + ], + + 'cache' => [ + /* + |-------------------------------------------------------------------------- + | Default cell caching driver + |-------------------------------------------------------------------------- + | + | By default PhpSpreadsheet keeps all cell values in memory, however when + | dealing with large files, this might result into memory issues. If you + | want to mitigate that, you can configure a cell caching driver here. + | When using the illuminate driver, it will store each value in a the + | cache store. This can slow down the process, because it needs to + | store each value. You can use the "batch" store if you want to + | only persist to the store when the memory limit is reached. + | + | Drivers: memory|illuminate|batch + | + */ + 'driver' => 'memory', + + /* + |-------------------------------------------------------------------------- + | Batch memory caching + |-------------------------------------------------------------------------- + | + | When dealing with the "batch" caching driver, it will only + | persist to the store when the memory limit is reached. + | Here you can tweak the memory limit to your liking. + | + */ + 'batch' => [ + 'memory_limit' => 60000, + ], + + /* + |-------------------------------------------------------------------------- + | Illuminate cache + |-------------------------------------------------------------------------- + | + | When using the "illuminate" caching driver, it will automatically use + | your default cache store. However if you prefer to have the cell + | cache on a separate store, you can configure the store name here. + | You can use any store defined in your cache config. When leaving + | at "null" it will use the default store. + | + */ + 'illuminate' => [ + 'store' => null, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Transaction Handler + |-------------------------------------------------------------------------- + | + | By default the import is wrapped in a transaction. This is useful + | for when an import may fail and you want to retry it. With the + | transactions, the previous import gets rolled-back. + | + | You can disable the transaction handler by setting this to null. + | Or you can choose a custom made transaction handler here. + | + | Supported handlers: null|db + | + */ + 'transactions' => [ + 'handler' => 'db', + ], + + 'temporary_files' => [ + + /* + |-------------------------------------------------------------------------- + | Local Temporary Path + |-------------------------------------------------------------------------- + | + | When exporting and importing files, we use a temporary file, before + | storing reading or downloading. Here you can customize that path. + | + */ + 'local_path' => storage_path('framework/laravel-excel'), + + /* + |-------------------------------------------------------------------------- + | Remote Temporary Disk + |-------------------------------------------------------------------------- + | + | When dealing with a multi server setup with queues in which you + | cannot rely on having a shared local temporary path, you might + | want to store the temporary file on a shared disk. During the + | queue executing, we'll retrieve the temporary file from that + | location instead. When left to null, it will always use + | the local path. This setting only has effect when using + | in conjunction with queued imports and exports. + | + */ + 'remote_disk' => null, + 'remote_prefix' => null, + + /* + |-------------------------------------------------------------------------- + | Force Resync + |-------------------------------------------------------------------------- + | + | When dealing with a multi server setup as above, it's possible + | for the clean up that occurs after entire queue has been run to only + | cleanup the server that the last AfterImportJob runs on. The rest of the server + | would still have the local temporary file stored on it. In this case your + | local storage limits can be exceeded and future imports won't be processed. + | To mitigate this you can set this config value to be true, so that after every + | queued chunk is processed the local temporary file is deleted on the server that + | processed it. + | + */ + 'force_resync_remote' => null, + ], +]; diff --git a/resources/views/layouts/base_portal.blade.php b/resources/views/layouts/base_portal.blade.php index 87144464..c12f1e3e 100644 --- a/resources/views/layouts/base_portal.blade.php +++ b/resources/views/layouts/base_portal.blade.php @@ -22,6 +22,17 @@ @@ -108,4 +119,4 @@
-@endsection \ No newline at end of file +@endsection diff --git a/routes/web.php b/routes/web.php index 2eb2bcbb..ca3457bc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -107,6 +107,8 @@ Route::get('/deliveries/refresh', function(){ Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download')->name('order.qr.download'); +Route::get('/report/customclearance', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance'); + //Route::get('/test', function(){ // $addresses = \App\Models\Address::all(); // foreach ($addresses as $address){ From b8a145cb5cf49470affa731b02e22ace916742a9 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Fri, 17 Sep 2021 07:12:08 +0800 Subject: [PATCH 05/52] Excel library, controllers --- .../Modules/Reports/ControllersLogic/ExportExcelLogic.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Classes/Modules/Reports/ControllersLogic/ExportExcelLogic.php b/app/Classes/Modules/Reports/ControllersLogic/ExportExcelLogic.php index ede392b4..c1d332a5 100644 --- a/app/Classes/Modules/Reports/ControllersLogic/ExportExcelLogic.php +++ b/app/Classes/Modules/Reports/ControllersLogic/ExportExcelLogic.php @@ -8,10 +8,9 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithHeadings; -use Maatwebsite\Excel\Concerns\WithEvents; use Maatwebsite\Excel\Concerns\ShouldAutoSize; -class ExportExcelLogic implements FromCollection, ShouldAutoSize, WithEvents, WithHeadings, WithColumnFormatting, WithMapping +class ExportExcelLogic implements FromCollection, ShouldAutoSize, WithHeadings, WithColumnFormatting, WithMapping { private $data; From ed637739cc06d8591e058ec7cd27f3a997ac89b1 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Mon, 27 Sep 2021 09:48:00 +0800 Subject: [PATCH 06/52] Inbound custom cleared --- .../Processors/CreateOrderRolesProcessor.php | 1 + .../Containers/InboundCustomClearedLogic.php | 66 +++++++++++ .../FetchInboundCustomClearedProcessor.php | 105 ++++++++++++++++++ .../InboundCustomClearedController.php | 20 ++++ resources/views/swagger/json.blade.php | 50 ++++++++- routes/packing_list.php | 2 + 6 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 app/Classes/Modules/PackingLists/ControllersLogic/Containers/InboundCustomClearedLogic.php create mode 100644 app/Classes/Modules/PackingLists/Processors/FetchInboundCustomClearedProcessor.php create mode 100644 app/Http/Controllers/PackingLists/Containers/InboundCustomClearedController.php diff --git a/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php b/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php index 0d4b1860..24495752 100644 --- a/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php +++ b/app/Classes/Modules/Orders/Processors/CreateOrderRolesProcessor.php @@ -79,6 +79,7 @@ class CreateOrderRolesProcessor $roleObject = new OrderRoleObject($order, $destinationWarehouse, OrderRoleTypes::DESTINATION_WAREHOUSE); $this->createsOrderRole->execute($roleObject); + $roleObject = new OrderRoleObject($order, $freightForwarder, OrderRoleTypes::LAST_MILE_DELIVERY_DRIVER); $this->createsOrderRole->execute($roleObject); diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/InboundCustomClearedLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/InboundCustomClearedLogic.php new file mode 100644 index 00000000..1df92ffa --- /dev/null +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/InboundCustomClearedLogic.php @@ -0,0 +1,66 @@ + 'Retrieved Containers', + 'message' => 'You have successfully retrieved a list of Containers' + ]; + } + + /** @var CanListContainers */ + private $canListContainers; + + /** @var ListsContainers */ + private $listsContainers; + + private $fetchInboundCustomCleared; + + /** + * ListContainersLogic constructor. + * @param CanListContainers $canListContainers + * @param ListsContainers $listsContainers + */ + public function __construct(CanListContainers $canListContainers, ListsContainers $listsContainers, FetchInboundCustomClearedProcessor $fetchInboundCustomCleared) + { + $this->canListContainers = $canListContainers; + $this->listsContainers = $listsContainers; + $this->fetchInboundCustomCleared = $fetchInboundCustomCleared; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + //$this->canListOrders->passes(); + + //$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true])); + + $d = $this->fetchInboundCustomCleared->execute(); + + return response()->json($d); + + } +} diff --git a/app/Classes/Modules/PackingLists/Processors/FetchInboundCustomClearedProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchInboundCustomClearedProcessor.php new file mode 100644 index 00000000..b4ea6395 --- /dev/null +++ b/app/Classes/Modules/PackingLists/Processors/FetchInboundCustomClearedProcessor.php @@ -0,0 +1,105 @@ +fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal; + $this->createsTransport = $createsTransport; + $this->createsSchedule = $createsSchedule; + $this->updatesContractObligations = $updatesContractObligations; + } + + + /** + * @return array + */ + public function execute(){ + + $packingLists = PackingList::query()->with(['steps' => function ($query) { + $query->where('steps.status', '<>', 3); + }])->first(); + dd($packingLists); + /* + $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::SUSPENDED])->get(); + + foreach($packingLists as $packingList){ + try { + $filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]'; + + $shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/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); + + $shippingPackingList = $shippingPackingLists->Rows[0]; + + if(!$shippingPackingList[9] && !$shippingPackingList[10]) { + continue; + } + + $packingList->status = ApprovalStatus::COMPLETED; + $packingList->save(); + + $deliveryDate = Carbon::parse($shippingPackingList[9] ? $shippingPackingList[9]:$shippingPackingList[10]); + $transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED); + $transport = $this->createsTransport->execute($transportObject, $packingList); + $this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED)); + + $deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first(); + $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; + $this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id); + $deliveryStep->update(['status' => ApprovalStatus::COMPLETED]); + + } catch (GuzzleException $exception) { + continue; + } + + }*/ + + + return []; + + } + + +} diff --git a/app/Http/Controllers/PackingLists/Containers/InboundCustomClearedController.php b/app/Http/Controllers/PackingLists/Containers/InboundCustomClearedController.php new file mode 100644 index 00000000..303ea5dc --- /dev/null +++ b/app/Http/Controllers/PackingLists/Containers/InboundCustomClearedController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} diff --git a/resources/views/swagger/json.blade.php b/resources/views/swagger/json.blade.php index 4fa056ef..cd4df686 100644 --- a/resources/views/swagger/json.blade.php +++ b/resources/views/swagger/json.blade.php @@ -107,6 +107,54 @@ } } }, + "/packing_list/container/inbound-custom-cleared": { + "get": { + "tags": [ + "Packing" + ], + "produces": [ + "application/json" + ], + "operationId": "listPackingIn", + "summary": "List packing", + "description": "", + "parameters": [ + { + "name": "filter", + "in": "query", + "description": "Filters", + "required": false, + "type": "array", + "items": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "headers": { + "X-Expires-After": { + "type": "string", + "format": "date-time", + "description": "date in UTC when token expires" + }, + "X-Rate-Limit": { + "type": "integer", + "format": "int32", + "description": "calls per hour allowed by the user" + } + }, + "schema": { + "type": "string" + } + }, + "422": { + "description": "Invalid input supplied" + } + } + } + }, "/packing_list/list": { "get": { "tags": [ @@ -2982,7 +3030,7 @@ } } }, - "/account/registration/registration": { + "/account/registration": { "post": { "tags": [ "Account", diff --git a/routes/packing_list.php b/routes/packing_list.php index ea64c7e1..11fc87ec 100644 --- a/routes/packing_list.php +++ b/routes/packing_list.php @@ -16,6 +16,8 @@ Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' = Route::post('/create', 'CreateContainerController@create')->name('create'); Route::put('/update/{id}', 'UpdateContainerController@update')->name('update'); Route::delete('/delete/{id}', 'DeleteContainerController@delete')->name('delete'); + + Route::get('/inbound-custom-cleared', 'InboundCustomClearedController@list')->name('list.inbound.custom.cleared'); }); Route::group(['namespace' => 'Packages', 'as' => 'package.', 'prefix' => 'package'], function () { From 27684a29408c55c0beca94d0089ff069d33edd26 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Mon, 27 Sep 2021 11:06:38 +0800 Subject: [PATCH 07/52] Changes to inline report --- .../Processors/FetchPackingListProcessor.php | 5 +++-- .../Reports/ControllersLogic/CustomcClearanceLogic.php | 3 ++- .../Reports/CustomcClearanceReportController.php | 3 ++- .../containers/elements/ContainerComponent.vue | 10 +++++++++- resources/views/layouts/base_portal.blade.php | 9 +-------- routes/web.php | 2 ++ 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/Classes/Modules/PackingLists/Processors/FetchPackingListProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchPackingListProcessor.php index b128aeed..508e2293 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchPackingListProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchPackingListProcessor.php @@ -33,14 +33,15 @@ class FetchPackingListProcessor * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\RequestValidationException */ - public function execute(){ + public function execute($params){ $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST) ->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED]) ->whereDoesntHave('containers', function($query){ $query->where('status', '=', ApprovalStatus::COMPLETED); - })->orderBy('created_at','desc')->limit(5)->get(); + })->orderBy('created_at','desc')->where('owner_id',$params['orderId'])->get(); + //dd($packingLists); $packingListsArray=[]; foreach($packingLists as $packingList){ diff --git a/app/Classes/Modules/Reports/ControllersLogic/CustomcClearanceLogic.php b/app/Classes/Modules/Reports/ControllersLogic/CustomcClearanceLogic.php index 5557c185..c7fa2c0d 100644 --- a/app/Classes/Modules/Reports/ControllersLogic/CustomcClearanceLogic.php +++ b/app/Classes/Modules/Reports/ControllersLogic/CustomcClearanceLogic.php @@ -25,7 +25,8 @@ class CustomcClearanceLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { - $packingLists = $this->listsPackingListProcessor->execute(); + $params = $request->all(); + $packingLists = $this->listsPackingListProcessor->execute($params); $excelExportLogic = new ExportExcelLogic(collect($packingLists)); $this->excelExportLogic = $excelExportLogic; diff --git a/app/Http/Controllers/Reports/CustomcClearanceReportController.php b/app/Http/Controllers/Reports/CustomcClearanceReportController.php index e7d24ff0..061f4a0b 100644 --- a/app/Http/Controllers/Reports/CustomcClearanceReportController.php +++ b/app/Http/Controllers/Reports/CustomcClearanceReportController.php @@ -9,7 +9,8 @@ use Maatwebsite\Excel\Facades\Excel; class CustomcClearanceReportController { - public function download(Request $request, CustomcClearanceLogic $customClearancelogic) { + public function download(int $orderId, Request $request, CustomcClearanceLogic $customClearancelogic) { + $request->merge(['orderId' => $orderId]); $filename = date("Y-m-d H:i:s")." - Custom cleared report "; $customClearancelogic->logic($request); return Excel::download( $customClearancelogic->getExcelCollection(), $filename.'.xlsx'); diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index e8af2c65..a6e53001 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -61,6 +61,14 @@
Release
Hold
+ @@ -96,4 +104,4 @@ }, mixins: [componentHandler] } - \ No newline at end of file + diff --git a/resources/views/layouts/base_portal.blade.php b/resources/views/layouts/base_portal.blade.php index c12f1e3e..96025829 100644 --- a/resources/views/layouts/base_portal.blade.php +++ b/resources/views/layouts/base_portal.blade.php @@ -23,14 +23,7 @@
Refresh Orders
diff --git a/routes/web.php b/routes/web.php index ca3457bc..f4d71a9c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -109,6 +109,8 @@ Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download Route::get('/report/customclearance', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance'); +Route::get('/report/customclearance/{orderid}', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance'); + //Route::get('/test', function(){ // $addresses = \App\Models\Address::all(); // foreach ($addresses as $address){ From aa39adaeb8907fd1be37aef104e10cf4fb7585c9 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Sep 2021 16:43:29 +0800 Subject: [PATCH 08/52] clean web routes --- routes/web.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/routes/web.php b/routes/web.php index 665b7297..9d7fc0a7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -108,15 +108,6 @@ Route::get('/deliveries/refresh', function(){ Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download')->name('order.qr.download'); -Route::get('/test', function(){ - $addresses = \App\Models\Address::all(); - foreach ($addresses as $address){ - $address->street_one = (new \App\Classes\Modules\Addresses\Services\CleansOldAddress())->cleanAddress($address->street_one, $address->district, $address->postcode); - $address->street_two = (new \App\Classes\Modules\Addresses\Services\CleansOldAddress())->cleanAddress($address->street_two, $address->district, $address->postcode); - $address->save(); - } -})->name('test'); - Route::get('/payments-and-billing', function () { return view('pages.templates.paymentsBilling'); })->name('payments-and-billing'); \ No newline at end of file From 09a3654e2fd73b83267974e754ecf82f2ab71cc7 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Sep 2021 17:05:58 +0800 Subject: [PATCH 09/52] add packing list inbound custom route --- routes/packing_list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/packing_list.php b/routes/packing_list.php index aa25028d..4eb27ddf 100644 --- a/routes/packing_list.php +++ b/routes/packing_list.php @@ -26,6 +26,7 @@ Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' = Route::post('/create', 'CreatePackageController@create')->name('create'); Route::put('/update/{id}', 'UpdatePackageController@update')->name('update'); Route::delete('/delete/{id}', 'DeletePackageController@delete')->name('delete'); + Route::get('/inbound-custom-cleared', 'InboundCustomClearedController@list')->name('list.inbound.custom.cleared'); Route::put('/switch-packing-list/{id}', 'SwitchPackagePackingListController@switch')->name('switch.packing_list'); Route::group(['namespace' => 'PackageItems', 'prefix' => 'item', 'as' => 'item.'], function () { From 2c3ea9e3f1e0892ec039c1c390465135a7e26751 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 28 Sep 2021 13:23:56 +0800 Subject: [PATCH 10/52] order component address tooltip layout fixes --- .../orders/elements/OrderComponent.vue | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/resources/assets/vue/components/orders/elements/OrderComponent.vue b/resources/assets/vue/components/orders/elements/OrderComponent.vue index c3104ca9..2262d768 100644 --- a/resources/assets/vue/components/orders/elements/OrderComponent.vue +++ b/resources/assets/vue/components/orders/elements/OrderComponent.vue @@ -2,7 +2,7 @@
-
+ -
+
Order No. @@ -28,8 +28,20 @@
- Delivery Address -
{{item.address.reference}}
+
+
+ Delivery Address +
+
+
+
+
{{item.address.reference}}
+
+
+
+ +
+
From 943f5ce64ee0be41500234f64dccbc30469653e0 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 28 Sep 2021 13:24:29 +0800 Subject: [PATCH 11/52] add custom clearance routes --- routes/web.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routes/web.php b/routes/web.php index 68121d43..01bc8f9a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -118,6 +118,10 @@ Route::get('/deliveries/refresh', function(){ Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download')->name('order.qr.download'); +Route::get('/report/customclearance', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance'); + +Route::get('/report/customclearance/{orderid}', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance'); + Route::get('/payments-and-billing', function () { return view('pages.templates.paymentsBilling'); })->name('payments-and-billing'); From 8e9db507f6a63c08f26a7f722a70a997fb6a605c Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 28 Sep 2021 15:55:24 +0800 Subject: [PATCH 12/52] fix template routes, and hide report button temp --- .../containers/elements/ContainerComponent.vue | 2 +- resources/views/partials/menu.blade.php | 4 ++-- routes/web.php | 17 ++++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index 694efdac..4b6ba607 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -68,7 +68,7 @@
Release
Hold
-
+
diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 8986d034..0d7693a5 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -93,7 +93,7 @@ style=" fill:#000000;">
@@ -115,7 +115,7 @@ style=" fill:#000000;">
diff --git a/routes/web.php b/routes/web.php index 01bc8f9a..2e98d3c8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -104,10 +104,6 @@ Route::get('/containers/refresh', function(){ })->name('containers.refresh'); -Route::get('/shipping-queue', function () { - return view('pages.templates.shippingQueue'); -})->name('shipping-queue'); - Route::get('/deliveries/refresh', function(){ FetchDeliveryListFromVTPortalJob::dispatch(); @@ -122,6 +118,13 @@ Route::get('/report/customclearance', 'Reports\CustomcClearanceReportController@ Route::get('/report/customclearance/{orderid}', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance'); -Route::get('/payments-and-billing', function () { - return view('pages.templates.paymentsBilling'); -})->name('payments-and-billing'); +Route::group(['prefix' => 'template', 'as' => 'template.'], function () { + Route::get('/payments-and-billing', function () { + return view('pages.templates.paymentsBilling'); + })->name('payments-and-billing'); + + Route::get('/shipping-queue', function () { + return view('pages.templates.shippingQueue'); + })->name('shipping-queue'); +}); + From 973ab58818a9f2cfdc8a94ba6aad2e831497e699 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Thu, 30 Sep 2021 16:12:48 +0800 Subject: [PATCH 13/52] hint claim id --- resources/views/pages/accounts/claim_business.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/pages/accounts/claim_business.blade.php b/resources/views/pages/accounts/claim_business.blade.php index 645b8e5f..dd199c15 100644 --- a/resources/views/pages/accounts/claim_business.blade.php +++ b/resources/views/pages/accounts/claim_business.blade.php @@ -8,6 +8,7 @@
+
{{$id}}
From c6e222caf2f9137d15806d40d2456db7a0dfd0d3 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:35:19 +0800 Subject: [PATCH 14/52] add loading date for container table --- .../Containers/CreateContainerLogic.php | 1 + .../Containers/UpdateContainerLogic.php | 7 +++++-- .../DataTransferObjects/ContainerObject.php | 17 ++++++++++++++++- ...tchLoadedContainersFromVTPortalProcessor.php | 10 +++++----- .../Services/Containers/CreatesContainer.php | 1 + ...021_07_21_110190_create_containers_table.php | 1 + 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerLogic.php index 40376b12..04802826 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerLogic.php @@ -62,6 +62,7 @@ class CreateContainerLogic extends AbstractControllerLogic $request->input('container_number'), $request->input('seal_reference'), $request->input('container_type'), + $request->input('loading_date'), $request->input('status') ); diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/UpdateContainerLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/UpdateContainerLogic.php index 72537db2..75eeddae 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/UpdateContainerLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/UpdateContainerLogic.php @@ -52,7 +52,9 @@ class UpdateContainerLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { @@ -64,7 +66,8 @@ class UpdateContainerLogic extends AbstractControllerLogic $container->container_number, $request->input('container_type'), $request->input('seal_reference'), - $container->status, + $request->input('loading_date'), + $container->status, ); $this->canUpdateContainer->passes($object); diff --git a/app/Classes/Modules/PackingLists/DataTransferObjects/ContainerObject.php b/app/Classes/Modules/PackingLists/DataTransferObjects/ContainerObject.php index 3924102c..d4ef5b40 100644 --- a/app/Classes/Modules/PackingLists/DataTransferObjects/ContainerObject.php +++ b/app/Classes/Modules/PackingLists/DataTransferObjects/ContainerObject.php @@ -3,6 +3,7 @@ namespace App\Classes\Modules\PackingLists\DataTransferObjects; use App\Classes\General\Interfaces\DataTransferObject; +use Carbon\Carbon; class ContainerObject implements DataTransferObject { @@ -19,6 +20,9 @@ class ContainerObject implements DataTransferObject /** @var int */ private $containerType; + /** @var Carbon */ + private $loadingDate; + /** @var int */ private $status; @@ -28,14 +32,16 @@ class ContainerObject implements DataTransferObject * @param string $containerNumber * @param string $sealReference * @param int $containerType + * @param Carbon $loadingDate * @param int $status */ - public function __construct(string $reference, string $containerNumber, string $sealReference, int $containerType, int $status) + public function __construct(string $reference, string $containerNumber, string $sealReference, int $containerType, Carbon $loadingDate, int $status) { $this->reference = $reference; $this->containerNumber = $containerNumber; $this->sealReference = $sealReference; $this->containerType = $containerType; + $this->loadingDate = $loadingDate; $this->status = $status; } @@ -71,6 +77,14 @@ class ContainerObject implements DataTransferObject return $this->containerType; } + /** + * @return Carbon + */ + public function getLoadingDate(): Carbon + { + return $this->loadingDate; + } + /** * @return int */ @@ -79,4 +93,5 @@ class ContainerObject implements DataTransferObject return $this->status; } + } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php index 23dc50ad..306f0312 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php @@ -6,7 +6,6 @@ use App\Classes\Exceptions\ResourceNotFoundException; use App\Classes\Modules\Companies\Services\FetchesCompanyModule; use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal; use App\Classes\Modules\Orders\Services\FetchesOrder; -use App\Classes\Modules\PackingList\Processors\GenerateShippingOrderStepsProcessor; use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject; use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject; use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer; @@ -124,9 +123,9 @@ class FetchLoadedContainersFromVTPortalProcessor */ public function execute(?Carbon $start = null, ?Carbon $end = null){ - DB::beginTransaction(); +// DB::beginTransaction(); try { - $start = $start ? $start : Carbon::now()->subMonth(); + $start = $start ? $start : Carbon::now()->subDays(5); $startLimit = Carbon::parse('11-08-2021'); @@ -148,7 +147,7 @@ class FetchLoadedContainersFromVTPortalProcessor $containerDetail = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailRequest); - $containerObject = new ContainerObject($container[0], str_replace(' ', '', $container[24]), str_replace(' ', '', $container[15]), ContainerTypes::FORTY_FEET_DRY_CONTAINER, 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); try { $container = $this->fetchesContainer->execute(['reference' => $containerObject->getReference()]); @@ -217,6 +216,7 @@ class FetchLoadedContainersFromVTPortalProcessor } } + dd('inserted'); } } catch (\Exception $exception){ @@ -224,7 +224,7 @@ class FetchLoadedContainersFromVTPortalProcessor } - DB::commit(); +// DB::commit(); return []; } diff --git a/app/Classes/Modules/PackingLists/Services/Containers/CreatesContainer.php b/app/Classes/Modules/PackingLists/Services/Containers/CreatesContainer.php index eb8ff4e0..41a608dc 100644 --- a/app/Classes/Modules/PackingLists/Services/Containers/CreatesContainer.php +++ b/app/Classes/Modules/PackingLists/Services/Containers/CreatesContainer.php @@ -23,6 +23,7 @@ class CreatesContainer extends AbstractUpdateRelationshipRecord $model->container_number = $object->getContainerNumber(); $model->container_type = $object->getContainerType(); $model->seal_reference = $object->getSealReference(); + $model->loading_date = $object->getLoadingDate(); $model->status = $object->getStatus(); return $this->handler($owner->containers(), $model); diff --git a/database/migrations/2021_07_21_110190_create_containers_table.php b/database/migrations/2021_07_21_110190_create_containers_table.php index 59ede968..f668901e 100644 --- a/database/migrations/2021_07_21_110190_create_containers_table.php +++ b/database/migrations/2021_07_21_110190_create_containers_table.php @@ -22,6 +22,7 @@ class CreateContainersTable extends Migration $table->string('container_number')->nullable(); $table->integer('container_type')->default(ContainerTypes::FORTY_FEET_DRY_CONTAINER); $table->string('seal_reference')->nullable(); + $table->timestamp('loading_date')->nullable(); $table->integer('status')->default(ApprovalStatus::PENDING_SUBMISSION); $table->softDeletes(); $table->timestamps(); From e5e00bb9ac773d1c7e0e73dd1cb00925ca3927cb Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:40:19 +0800 Subject: [PATCH 15/52] test updating loading date for containers from vt portal --- routes/web.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/routes/web.php b/routes/web.php index 2e98d3c8..d7d61856 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,6 +5,7 @@ use App\Classes\Jobs\FetchDeliveryListFromVTPortalJob; use App\Classes\Jobs\FetchLoadedContainersFromVTPortalJob; use App\Classes\Jobs\FetchPackingListFromVTPortalJob; use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob; +use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal; use App\Models\CompanyConnection; use Illuminate\Support\Facades\Crypt; use App\Models\Container; @@ -128,3 +129,28 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { })->name('shipping-queue'); }); +Route::get('/report', function(){ + $fetchesDataFRomVTPortal = App()->make(FetchesDataFromVTPortal::class); + foreach(Container::all() as $container) { + $filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]'; + + $containerDetailsRequest = $fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), ''); + + $containerDetails = $fetchesDataFRomVTPortal->getResponseBody($containerDetailsRequest); + + $containerDetails = $containerDetails->Rows[0]; + + dd($containerDetails); + + } +// $shipping_packing_lists = \App\Models\PackingList::where('type', '=', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get(); +// +// $totalCbm = $shipping_packing_lists->sum(function($packing_list){ +// return $packing_list->packages->sum(function ($package){ +// return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)); +// }); +// }); +// +// echo 'total cbm: '.$totalCbm; +}); + From b9b05dfdbe7a513777c457ad3fa8b7d092da421e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:41:42 +0800 Subject: [PATCH 16/52] test updating loading date for containers from vt portal --- routes/web.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index d7d61856..779e59cf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -140,7 +140,8 @@ Route::get('/report', function(){ $containerDetails = $containerDetails->Rows[0]; - dd($containerDetails); + $container->loading_date = $containerDetails[5]; + $container->save(); } // $shipping_packing_lists = \App\Models\PackingList::where('type', '=', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get(); From 7c14b74dd1d367bdaf4bd79ac50ef8813c9629e1 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:42:44 +0800 Subject: [PATCH 17/52] test updating loading date for containers from vt portal --- routes/web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/web.php b/routes/web.php index 779e59cf..e97f66fa 100644 --- a/routes/web.php +++ b/routes/web.php @@ -132,6 +132,7 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { Route::get('/report', function(){ $fetchesDataFRomVTPortal = App()->make(FetchesDataFromVTPortal::class); foreach(Container::all() as $container) { + dd(count(Container::all())); $filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]'; $containerDetailsRequest = $fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), ''); From e93da67ec1b508cad65c3968990c66a0c8664298 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:43:46 +0800 Subject: [PATCH 18/52] test updating loading date for containers from vt portal --- routes/web.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index e97f66fa..51874583 100644 --- a/routes/web.php +++ b/routes/web.php @@ -132,7 +132,7 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { Route::get('/report', function(){ $fetchesDataFRomVTPortal = App()->make(FetchesDataFromVTPortal::class); foreach(Container::all() as $container) { - dd(count(Container::all())); + $filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]'; $containerDetailsRequest = $fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), ''); @@ -141,7 +141,7 @@ Route::get('/report', function(){ $containerDetails = $containerDetails->Rows[0]; - $container->loading_date = $containerDetails[5]; + $container->loading_date = \Carbon\Carbon::parse($containerDetails[5]); $container->save(); } From 2974fe4e9a38733b6dda79b3ffdf39376476e181 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:44:20 +0800 Subject: [PATCH 19/52] test updating loading date for containers from vt portal --- routes/web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/web.php b/routes/web.php index 51874583..c3f98f38 100644 --- a/routes/web.php +++ b/routes/web.php @@ -142,6 +142,7 @@ Route::get('/report', function(){ $containerDetails = $containerDetails->Rows[0]; $container->loading_date = \Carbon\Carbon::parse($containerDetails[5]); + dd($container); $container->save(); } From 9b9292546bf80f3fae5c1d6b4beca25c2b8ddafe Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:45:37 +0800 Subject: [PATCH 20/52] test updating loading date for containers from vt portal --- routes/web.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/routes/web.php b/routes/web.php index c3f98f38..223efee7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -133,17 +133,21 @@ Route::get('/report', function(){ $fetchesDataFRomVTPortal = App()->make(FetchesDataFromVTPortal::class); foreach(Container::all() as $container) { - $filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]'; + try { + $filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]'; - $containerDetailsRequest = $fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), ''); + $containerDetailsRequest = $fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), ''); - $containerDetails = $fetchesDataFRomVTPortal->getResponseBody($containerDetailsRequest); + $containerDetails = $fetchesDataFRomVTPortal->getResponseBody($containerDetailsRequest); - $containerDetails = $containerDetails->Rows[0]; + $containerDetails = $containerDetails->Rows[0]; - $container->loading_date = \Carbon\Carbon::parse($containerDetails[5]); - dd($container); - $container->save(); + $container->loading_date = \Carbon\Carbon::parse($containerDetails[5]); + $container->save(); + + } catch (Exception $exception){ +dd($exception); + } } // $shipping_packing_lists = \App\Models\PackingList::where('type', '=', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get(); From 9ef636c5d503f5b0a7045b3d3ebab3a15147b9eb Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:49:59 +0800 Subject: [PATCH 21/52] add container loading date --- app/Http/Resources/ContainerResource.php | 1 + .../vue/components/containers/elements/ContainerComponent.vue | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/Http/Resources/ContainerResource.php b/app/Http/Resources/ContainerResource.php index bc6337cc..b9daa54f 100644 --- a/app/Http/Resources/ContainerResource.php +++ b/app/Http/Resources/ContainerResource.php @@ -21,6 +21,7 @@ class ContainerResource extends JsonResource 'container_specification' => ContainerTypes::CONTAINER_SPECIFICATION[$this->container_type], 'container_number' => $this->container_number, 'seal_reference' => $this->seal_reference, + 'loading_date' => $this->loading_date ? $this->loading_date->format('d-m-Y') : $this->loading_date, 'transport' => new TransportResource($this->transports()->first()), 'packing_lists' => PackingListResource::collection($this->whenLoaded('packingLists', function(){ return $this->packingLists()->whereHas('packages')->get(); diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index 4b6ba607..ba965739 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -14,6 +14,10 @@
{{item.container_reference}}

{{item.container_number}} / {{item.seal_reference}}

+
+

Loading Date

+

{{item.loading_date ? item.loading_date : 'n/a'}}

+

ETD

{{item.transport ? item.transport.current_schedule.etd : 'n/a'}}

From c66273874d5251e4965fb6623f2abcc5b0502a4e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:52:28 +0800 Subject: [PATCH 22/52] marking container loading date as a timestamp in the modal --- app/Models/Container.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Models/Container.php b/app/Models/Container.php index 9ff4fde8..e9acf41e 100644 --- a/app/Models/Container.php +++ b/app/Models/Container.php @@ -15,6 +15,8 @@ class Container extends AbstractModel implements Transportable protected $fillable = ['status']; + protected $dates = ['loading_date']; + public function packingLists(): belongsToMany { return $this->belongsToMany(PackingList::class, ContainerPackingList::class, 'container_id', 'packing_list_id'); From 2305ddb39d2c089452de8fad0e335c234fac9177 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 17:55:06 +0800 Subject: [PATCH 23/52] fix container component ui --- .../components/containers/elements/ContainerComponent.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index ba965739..7f8f627f 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -14,15 +14,15 @@
{{item.container_reference}}

{{item.container_number}} / {{item.seal_reference}}

-
+

Loading Date

{{item.loading_date ? item.loading_date : 'n/a'}}

-
+

ETD

{{item.transport ? item.transport.current_schedule.etd : 'n/a'}}

-
+

ETA

{{item.transport ? item.transport.current_schedule.eta : 'n/a'}}

@@ -30,7 +30,7 @@

Loaded CBM

{{ (Math.ceil((item.packing_lists.reduce((total, obj) => total + obj.packages.reduce((total, obj) => obj.cbm + total, 0), 0)) * 1000) / 1000).toFixed(3) }}

-
+

Status

{{item.status === 3 ? 'Un-stuffed' : 'In Progress'}}

From 26a0bc186e91cb4a8b5277a995328f0f0170c572 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:00:07 +0800 Subject: [PATCH 24/52] total loaded cbm monthly report --- routes/web.php | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/routes/web.php b/routes/web.php index 223efee7..1fda2f3a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -130,34 +130,14 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { }); Route::get('/report', function(){ - $fetchesDataFRomVTPortal = App()->make(FetchesDataFromVTPortal::class); - foreach(Container::all() as $container) { + $totalCbm = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get()->sum(function($container){ + $container->packingLists->sum(function($packing_list){ + return $packing_list->packages->sum(function ($package){ + return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)); + }); + }); + }); - try { - $filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]'; - - $containerDetailsRequest = $fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), ''); - - $containerDetails = $fetchesDataFRomVTPortal->getResponseBody($containerDetailsRequest); - - $containerDetails = $containerDetails->Rows[0]; - - $container->loading_date = \Carbon\Carbon::parse($containerDetails[5]); - $container->save(); - - } catch (Exception $exception){ -dd($exception); - } - - } -// $shipping_packing_lists = \App\Models\PackingList::where('type', '=', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get(); -// -// $totalCbm = $shipping_packing_lists->sum(function($packing_list){ -// return $packing_list->packages->sum(function ($package){ -// return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)); -// }); -// }); -// -// echo 'total cbm: '.$totalCbm; + echo 'total cbm: '. $totalCbm; }); From c76271d8ab72a00c650f6e1b07b7d7198be15234 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:02:09 +0800 Subject: [PATCH 25/52] loaded cbm monthly report --- routes/web.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index 1fda2f3a..a4a09574 100644 --- a/routes/web.php +++ b/routes/web.php @@ -130,8 +130,9 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { }); Route::get('/report', function(){ - $totalCbm = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get()->sum(function($container){ - $container->packingLists->sum(function($packing_list){ + $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); + $totalCbm = $containers->sum(function($container){ + return $container->packingLists->sum(function($packing_list){ return $packing_list->packages->sum(function ($package){ return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)); }); From 9221bd094c413451305b6b13112752c24b7a3874 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:11:15 +0800 Subject: [PATCH 26/52] count total containers --- routes/web.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routes/web.php b/routes/web.php index a4a09574..29de21f6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -131,6 +131,8 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { Route::get('/report', function(){ $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); + + dd(count($containers)); $totalCbm = $containers->sum(function($container){ return $container->packingLists->sum(function($packing_list){ return $packing_list->packages->sum(function ($package){ From 96d701bc805078d10df47ed57050fa036fd7239f Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:14:46 +0800 Subject: [PATCH 27/52] container monthly report --- routes/web.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/routes/web.php b/routes/web.php index 29de21f6..f4e8e837 100644 --- a/routes/web.php +++ b/routes/web.php @@ -132,15 +132,20 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { Route::get('/report', function(){ $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); - dd(count($containers)); - $totalCbm = $containers->sum(function($container){ - return $container->packingLists->sum(function($packing_list){ + $total = 0; + + foreach ($containers as $container){ + $cbm = $container->packingLists->sum(function($packing_list){ return $packing_list->packages->sum(function ($package){ return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)); }); }); - }); - echo 'total cbm: '. $totalCbm; + $total += $cbm; + + echo $container->reference.': '.$cbm; + } + + echo 'total cbm: '. $total; }); From 6c5bbf842ee3c9adcd8274243a9a779ff4e22919 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:16:56 +0800 Subject: [PATCH 28/52] container report --- routes/web.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index f4e8e837..dcb0ac54 100644 --- a/routes/web.php +++ b/routes/web.php @@ -143,9 +143,9 @@ Route::get('/report', function(){ $total += $cbm; - echo $container->reference.': '.$cbm; + echo $container->reference.': '.$cbm.'


'; } - echo 'total cbm: '. $total; + echo '


total cbm: '. $total; }); From 1af45e513261c40c234b4810741f53abc5bf8ecf Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:17:17 +0800 Subject: [PATCH 29/52] container monthly report --- database/seeders/CompaniesTableSeeder.php | 60 +++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/database/seeders/CompaniesTableSeeder.php b/database/seeders/CompaniesTableSeeder.php index c2ffdeb4..22990fd2 100644 --- a/database/seeders/CompaniesTableSeeder.php +++ b/database/seeders/CompaniesTableSeeder.php @@ -172,49 +172,49 @@ class CompaniesTableSeeder extends Seeder } - // if(true){ - // $companies = OldCompany::all(); + if(true){ + $companies = OldCompany::all(); - // foreach($companies as $company){ + foreach($companies as $company){ - // $marking = explode("CIEF/", $company->marking); + $marking = explode("CIEF/", $company->marking); - // if(count($marking) < 2){ - // continue; - // } + if(count($marking) < 2){ + continue; + } - // $marking = str_replace(' ', '', str_replace('/', '', $marking[1])); + $marking = str_replace(' ', '', str_replace('/', '', $marking[1])); - // /** @var Company $newCompany */ - // $newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION); + /** @var Company $newCompany */ + $newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION); - // $this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED); + $this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED); - // /** @var CompanyModule $companyModule */ - // $companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER); + /** @var CompanyModule $companyModule */ + $companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER); - // $connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking); + $connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking); - // $connection = $this->createsCompanyConnection->execute($connectionObject); - // $this->approvesCompanyConnection->execute($connection); + $connection = $this->createsCompanyConnection->execute($connectionObject); + $this->approvesCompanyConnection->execute($connection); - // $i = 0; - // foreach($company->addresses as $address){ - // $this->createAddressFromOldAddressProcessor->execute($address, $companyModule); - // $contact = preg_replace("/[^0-9.]/", "", $address->contact); - // if($contact){ - // $i++; - // if($i === 1) { - // $contactObject = new ContactObject('', $contact, $company->email, '',); - // $this->createContactProcessor->execute($contactObject, $newCompany); - // } - // } + $i = 0; + foreach($company->addresses as $address){ + $this->createAddressFromOldAddressProcessor->execute($address, $companyModule); + $contact = preg_replace("/[^0-9.]/", "", $address->contact); + if($contact){ + $i++; + if($i === 1) { + $contactObject = new ContactObject('', $contact, $company->email, '',); + $this->createContactProcessor->execute($contactObject, $newCompany); + } + } - // } - // } - // } + } + } + } } From 8f381b42f300c6862e8ec7e47b78bc6eaf07f58f Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:18:40 +0800 Subject: [PATCH 30/52] container monthly report --- database/seeders/CompaniesTableSeeder.php | 86 +++++++++++------------ routes/web.php | 2 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/database/seeders/CompaniesTableSeeder.php b/database/seeders/CompaniesTableSeeder.php index 22990fd2..da6c1061 100644 --- a/database/seeders/CompaniesTableSeeder.php +++ b/database/seeders/CompaniesTableSeeder.php @@ -172,49 +172,49 @@ class CompaniesTableSeeder extends Seeder } - if(true){ - $companies = OldCompany::all(); - - foreach($companies as $company){ - - $marking = explode("CIEF/", $company->marking); - - if(count($marking) < 2){ - continue; - } - - $marking = str_replace(' ', '', str_replace('/', '', $marking[1])); - - - /** @var Company $newCompany */ - $newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION); - - $this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED); - - /** @var CompanyModule $companyModule */ - $companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER); - - $connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking); - - $connection = $this->createsCompanyConnection->execute($connectionObject); - $this->approvesCompanyConnection->execute($connection); - - $i = 0; - foreach($company->addresses as $address){ - $this->createAddressFromOldAddressProcessor->execute($address, $companyModule); - $contact = preg_replace("/[^0-9.]/", "", $address->contact); - if($contact){ - $i++; - if($i === 1) { - $contactObject = new ContactObject('', $contact, $company->email, '',); - $this->createContactProcessor->execute($contactObject, $newCompany); - } - } - - - } - } - } +// if(true){ +// $companies = OldCompany::all(); +// +// foreach($companies as $company){ +// +// $marking = explode("CIEF/", $company->marking); +// +// if(count($marking) < 2){ +// continue; +// } +// +// $marking = str_replace(' ', '', str_replace('/', '', $marking[1])); +// +// +// /** @var Company $newCompany */ +// $newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION); +// +// $this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED); +// +// /** @var CompanyModule $companyModule */ +// $companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER); +// +// $connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking); +// +// $connection = $this->createsCompanyConnection->execute($connectionObject); +// $this->approvesCompanyConnection->execute($connection); +// +// $i = 0; +// foreach($company->addresses as $address){ +// $this->createAddressFromOldAddressProcessor->execute($address, $companyModule); +// $contact = preg_replace("/[^0-9.]/", "", $address->contact); +// if($contact){ +// $i++; +// if($i === 1) { +// $contactObject = new ContactObject('', $contact, $company->email, '',); +// $this->createContactProcessor->execute($contactObject, $newCompany); +// } +// } +// +// +// } +// } +// } } diff --git a/routes/web.php b/routes/web.php index dcb0ac54..b0976c5c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -143,7 +143,7 @@ Route::get('/report', function(){ $total += $cbm; - echo $container->reference.': '.$cbm.'


'; + echo $container->reference.': '.$cbm.'

'; } echo '


total cbm: '. $total; From 27e856bc4d9263ac9687aac9f0740026fbbee017 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:23:10 +0800 Subject: [PATCH 31/52] container monthly report --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index b0976c5c..9513ff80 100644 --- a/routes/web.php +++ b/routes/web.php @@ -143,7 +143,7 @@ Route::get('/report', function(){ $total += $cbm; - echo $container->reference.': '.$cbm.'

'; + echo $container->reference.'

'; } echo '


total cbm: '. $total; From 463d342441c5d7cd33a70d6fa0a2010cf41ab33e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:33:19 +0800 Subject: [PATCH 32/52] container monthly report --- .../elements/ContainerProfileSectionComponent.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue b/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue index b63f317c..a7245d1f 100644 --- a/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue @@ -16,6 +16,18 @@

Container Type: {{container.container_type}}

+
+
+
+
+
total cbm
+
+
+
+
+
{{ (Math.ceil((container.packing_lists.reduce((total, obj) => total + obj.packages.reduce((total, obj) => obj.cbm + total, 0), 0)) * 1000) / 1000).toFixed(3) }}
+
+
From 933f39d280411ab8ee89e3286d41f238a61a7603 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 18:33:29 +0800 Subject: [PATCH 33/52] container monthly report --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 9513ff80..b0976c5c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -143,7 +143,7 @@ Route::get('/report', function(){ $total += $cbm; - echo $container->reference.'

'; + echo $container->reference.': '.$cbm.'

'; } echo '


total cbm: '. $total; From bf7443887ca65803cb4ea7af8034e2a14bff06bf Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:26:42 +0800 Subject: [PATCH 34/52] customer report --- routes/web.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/routes/web.php b/routes/web.php index b0976c5c..29757f4b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -133,19 +133,35 @@ Route::get('/report', function(){ $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); $total = 0; + $customers = []; foreach ($containers as $container){ - $cbm = $container->packingLists->sum(function($packing_list){ - return $packing_list->packages->sum(function ($package){ + foreach($container->packingLists as $packingList){ + $cbm = $packingList->packages->sum(function ($package){ return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)); }); - }); - $total += $cbm; + $total += $cbm; + if(!array_key_exists($packingList->owner->id, $customers)){ + $marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; + $customers[$packingList->owner->id] = [ + 'marking' => $marking, + 'cbm' => $cbm, + 'packages' => $packingList->packages->sum('quantity') + ]; - echo $container->reference.': '.$cbm.'

'; + continue; + } + + $customers[$packingList->owner->id]['cbm'] += $cbm; + $customers[$packingList->owner->id]['packages'] += $packingList->packages->sum('quantity'); + } } + dd($customers); + echo '


total cbm: '. $total; + + }); From 7bde77036d5d3e11ad3d3726f6146c7bf09c4416 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:34:25 +0800 Subject: [PATCH 35/52] customer report --- routes/web.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index 29757f4b..7152d940 100644 --- a/routes/web.php +++ b/routes/web.php @@ -133,7 +133,7 @@ Route::get('/report', function(){ $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); $total = 0; - $customers = []; + $customers = collect(); foreach ($containers as $container){ foreach($container->packingLists as $packingList){ @@ -142,13 +142,13 @@ Route::get('/report', function(){ }); $total += $cbm; - if(!array_key_exists($packingList->owner->id, $customers)){ + if(!$customers->has($packingList->owner->id)){ $marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; - $customers[$packingList->owner->id] = [ + $customers->put($packingList->owner->id, collect([ 'marking' => $marking, 'cbm' => $cbm, 'packages' => $packingList->packages->sum('quantity') - ]; + ])); continue; } From ccd7d910768846993655568c5b992241c41b6ae4 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:35:55 +0800 Subject: [PATCH 36/52] customer report --- routes/web.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 7152d940..8c51c96f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -158,7 +158,9 @@ Route::get('/report', function(){ } } - dd($customers); + dd($customers->sortBy(function($customer){ + return $customer['cbm']; + })); echo '


total cbm: '. $total; From 8b5ac008d3a710a0241480c764df13cde84f9076 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:37:12 +0800 Subject: [PATCH 37/52] customer report --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 8c51c96f..121266d5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -158,7 +158,7 @@ Route::get('/report', function(){ } } - dd($customers->sortBy(function($customer){ + dd($customers->sortByDesc(function($customer){ return $customer['cbm']; })); From 626ba6bbf42a7899178115d8647ad23a26f8839d Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:40:12 +0800 Subject: [PATCH 38/52] customer report --- routes/web.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index 121266d5..501ec216 100644 --- a/routes/web.php +++ b/routes/web.php @@ -142,10 +142,9 @@ Route::get('/report', function(){ }); $total += $cbm; - if(!$customers->has($packingList->owner->id)){ - $marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; - $customers->put($packingList->owner->id, collect([ - 'marking' => $marking, + $marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; + if(!$customers->has($marking)){ + $customers->put($marking, collect([ 'cbm' => $cbm, 'packages' => $packingList->packages->sum('quantity') ])); From 87e9dbe3ec692bb1a7f635d45224e935dcc82e5b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:43:50 +0800 Subject: [PATCH 39/52] customer report --- routes/web.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/routes/web.php b/routes/web.php index 501ec216..d5a53e8a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -143,8 +143,9 @@ Route::get('/report', function(){ $total += $cbm; $marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; - if(!$customers->has($marking)){ + if(!$customers->has($packingList->owner->id)){ $customers->put($marking, collect([ + 'marking' => $marking, 'cbm' => $cbm, 'packages' => $packingList->packages->sum('quantity') ])); @@ -152,8 +153,8 @@ Route::get('/report', function(){ continue; } - $customers[$packingList->owner->id]['cbm'] += $cbm; - $customers[$packingList->owner->id]['packages'] += $packingList->packages->sum('quantity'); + $customers[$marking]['cbm'] += $cbm; + $customers[$marking]['packages'] += $packingList->packages->sum('quantity'); } } From 2f1166653960732503f99d7449427820f2858966 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:46:00 +0800 Subject: [PATCH 40/52] customer report --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index d5a53e8a..5d278380 100644 --- a/routes/web.php +++ b/routes/web.php @@ -157,7 +157,7 @@ Route::get('/report', function(){ $customers[$marking]['packages'] += $packingList->packages->sum('quantity'); } } - +dd($total); dd($customers->sortByDesc(function($customer){ return $customer['cbm']; })); From 186d6f71c6ad59080d2adc229e3110cf8cc701aa Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:48:04 +0800 Subject: [PATCH 41/52] customer report --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 5d278380..47c4593c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -130,7 +130,7 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { }); Route::get('/report', function(){ - $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); + $containers = Container::all(); $total = 0; $customers = collect(); From 1e5df1d64bbae2d4d87c2aea309a034ea06eb4ee Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 19:50:44 +0800 Subject: [PATCH 42/52] customer report --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 47c4593c..6158247a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -131,7 +131,7 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { Route::get('/report', function(){ $containers = Container::all(); - +dd($containers); $total = 0; $customers = collect(); From 557d85ef8d5759e6c1b444e1f2ef1c2484720f8b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 20:45:00 +0800 Subject: [PATCH 43/52] customer report --- routes/web.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/routes/web.php b/routes/web.php index 6158247a..3b32037e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -130,22 +130,26 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { }); Route::get('/report', function(){ - $containers = Container::all(); -dd($containers); + $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); + $total = 0; $customers = collect(); foreach ($containers as $container){ + echo ''.$container->reference.': '.$container->packingLists->sum(function($packingList){ + return $packingList->packages->sum(function ($package){ + return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity; + }); + }).'CBM

'; foreach($container->packingLists as $packingList){ $cbm = $packingList->packages->sum(function ($package){ - return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)); + return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity; }); $total += $cbm; $marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; - if(!$customers->has($packingList->owner->id)){ + if(!$customers->has($marking)){ $customers->put($marking, collect([ - 'marking' => $marking, 'cbm' => $cbm, 'packages' => $packingList->packages->sum('quantity') ])); @@ -157,12 +161,15 @@ dd($containers); $customers[$marking]['packages'] += $packingList->packages->sum('quantity'); } } -dd($total); - dd($customers->sortByDesc(function($customer){ - return $customer['cbm']; - })); - echo '


total cbm: '. $total; + echo '

total cbm: '. $total . '

'; + echo '

active customers: '. count($customers) . '



'; + + foreach ($customers->sortByDesc(function($customer){ + return $customer['cbm']; + }) as $marking => $customer) { + echo ''.$marking.': '.$customer['cbm'].' CBM ( '.$customer['packages'].' ) CTNS

'; + } }); From feb04e84986a5fed46a0059df6da25a0bd759488 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 21:14:33 +0800 Subject: [PATCH 44/52] customer report --- routes/web.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 3b32037e..93bf2cc7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -151,6 +151,7 @@ Route::get('/report', function(){ if(!$customers->has($marking)){ $customers->put($marking, collect([ 'cbm' => $cbm, + 'orders' => 1, 'packages' => $packingList->packages->sum('quantity') ])); @@ -158,6 +159,7 @@ Route::get('/report', function(){ } $customers[$marking]['cbm'] += $cbm; + $customers[$marking]['orders'] += 1; $customers[$marking]['packages'] += $packingList->packages->sum('quantity'); } } @@ -165,10 +167,12 @@ Route::get('/report', function(){ echo '

total cbm: '. $total . '

'; echo '

active customers: '. count($customers) . '



'; + $i = 1; foreach ($customers->sortByDesc(function($customer){ return $customer['cbm']; }) as $marking => $customer) { - echo ''.$marking.': '.$customer['cbm'].' CBM ( '.$customer['packages'].' ) CTNS

'; + echo ''.$i.'. '.$marking.': '.$customer['cbm'].' CBM ('. $customer['orders'] .' - '.$customer['packages'].' ) CTNS

'; + $i++; } From 019073afc5cd5a5bed701a50486d3ce870d6b05a Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 1 Oct 2021 21:25:02 +0800 Subject: [PATCH 45/52] customer report --- .../FetchLoadedContainersFromVTPortalProcessor.php | 5 ++--- routes/web.php | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php index 306f0312..5df560d4 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php @@ -123,7 +123,7 @@ class FetchLoadedContainersFromVTPortalProcessor */ public function execute(?Carbon $start = null, ?Carbon $end = null){ -// DB::beginTransaction(); + DB::beginTransaction(); try { $start = $start ? $start : Carbon::now()->subDays(5); @@ -216,7 +216,6 @@ class FetchLoadedContainersFromVTPortalProcessor } } - dd('inserted'); } } catch (\Exception $exception){ @@ -224,7 +223,7 @@ class FetchLoadedContainersFromVTPortalProcessor } -// DB::commit(); + DB::commit(); return []; } diff --git a/routes/web.php b/routes/web.php index 93bf2cc7..c0023a55 100644 --- a/routes/web.php +++ b/routes/web.php @@ -130,7 +130,7 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { }); Route::get('/report', function(){ - $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); + $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->orderBy('loading_date')->get(); $total = 0; $customers = collect(); @@ -140,7 +140,7 @@ Route::get('/report', function(){ return $packingList->packages->sum(function ($package){ return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity; }); - }).'CBM

'; + }).'CBM ('. $container->loading_date->format('d-m-Y') .')

'; foreach($container->packingLists as $packingList){ $cbm = $packingList->packages->sum(function ($package){ return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity; From bbc247d67e38bc72cabc34c568a0c9282c3a6085 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 2 Oct 2021 14:59:15 +0800 Subject: [PATCH 46/52] customer report --- .../Reports/MonthlyReportController.php | 62 +++++++ .../MonthlyReportSectionComponent.vue | 168 ++++++++++++++++++ .../views/pages/admin/customers.blade.php | 25 +++ .../views/pages/admin/dashboard.blade.php | 73 ++++---- resources/views/partials/menu.blade.php | 11 ++ routes/api.php | 2 + routes/web.php | 6 + 7 files changed, 308 insertions(+), 39 deletions(-) create mode 100644 app/Http/Controllers/Reports/MonthlyReportController.php create mode 100644 resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue create mode 100644 resources/views/pages/admin/customers.blade.php diff --git a/app/Http/Controllers/Reports/MonthlyReportController.php b/app/Http/Controllers/Reports/MonthlyReportController.php new file mode 100644 index 00000000..abc55895 --- /dev/null +++ b/app/Http/Controllers/Reports/MonthlyReportController.php @@ -0,0 +1,62 @@ +whereYear('loading_date', '=', '2021')->orderBy('loading_date')->get(); + + $total = 0; + $customers = collect(); + + foreach ($containers as $container){ + foreach($container->packingLists as $packingList){ + $cbm = $packingList->packages->sum(function ($package){ + return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity; + }); + + $total += $cbm; + $marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; + if(!$customers->has($marking)){ + $customers->put($marking, collect([ + 'cbm' => $cbm, + 'orders' => 1, + 'packages' => $packingList->packages->sum('quantity') + ])); + + continue; + } + + $customers[$marking]['cbm'] += $cbm; + $customers[$marking]['orders'] += 1; + $customers[$marking]['packages'] += $packingList->packages->sum('quantity'); + } + } + + $activeOrders = $customers->sum(function($customer){ + return $customer['orders']; + }); + return (new ApiResponseObject('fetch monthly report Successful', + '', + HttpStatus::OK_WITH_MESSAGE, ['data' => [ + 'containers' => count($containers), + 'activated_orders' => $activeOrders, + 'active_customers' => count($customers), + 'total_cbm' => $customers->sum(function($customer){ + return $customer['cbm']; + }), + 'packages' => $customers->sum(function($customer){ + return $customer['packages']; + }), + 'total_orders' => Order::whereMonth('created_at', 9)->whereHas('packingLists')->count() + ]]))->handler(); + } +} diff --git a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue new file mode 100644 index 00000000..d40eea3d --- /dev/null +++ b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue @@ -0,0 +1,168 @@ + + \ No newline at end of file diff --git a/resources/views/pages/admin/customers.blade.php b/resources/views/pages/admin/customers.blade.php new file mode 100644 index 00000000..048b81c6 --- /dev/null +++ b/resources/views/pages/admin/customers.blade.php @@ -0,0 +1,25 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+
+
+
+
+
Customers List
+
+
+
+
+ + + +
+
+
+
+
+
+@endsection diff --git a/resources/views/pages/admin/dashboard.blade.php b/resources/views/pages/admin/dashboard.blade.php index 0fe49ba7..f5b7df56 100644 --- a/resources/views/pages/admin/dashboard.blade.php +++ b/resources/views/pages/admin/dashboard.blade.php @@ -1,47 +1,42 @@
-
-
-
-
Customers List
-
-
-
+
+
- - - +
-
-
-
-
-
Identification Verification
+
+
+
+
+
Identification Verification
+
+
+
+
+ + + +
+
-
-
-
- - - -
-
-
-
-
Address Change Verification
-
-
-
-
- - - +
+
+
+
Address Change Verification
+
+
+
+
+ + + +
+
diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 0d7693a5..c32eb3df 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -30,6 +30,17 @@
Dashboard
+
+
+ +
+
+
Customers
+
+
'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/schedule.php'; + Route::get('/report', 'Reports\MonthlyReportController@report')->name('report'); + }); }); diff --git a/routes/web.php b/routes/web.php index c0023a55..5e4cba15 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,6 +7,7 @@ use App\Classes\Jobs\FetchPackingListFromVTPortalJob; use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob; use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal; use App\Models\CompanyConnection; +use App\Models\Order; use Illuminate\Support\Facades\Crypt; use App\Models\Container; use Illuminate\Support\Facades\Route; @@ -53,6 +54,10 @@ Route::get('/dashboard', function () { return view('pages.dashboard'); })->name('dashboard'); +Route::get('/customers', function () { + return view('pages.admin.customers'); +})->name('customers'); + Route::get('/orders', function () { return view('pages.orders.index'); })->name('orders'); @@ -178,3 +183,4 @@ Route::get('/report', function(){ }); + From 24a286a5a2a6da0e9d8c79302cd4221fc50e9675 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 2 Oct 2021 15:00:49 +0800 Subject: [PATCH 47/52] customer report --- .../reports/sections/MonthlyReportSectionComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue index d40eea3d..f3d3bf36 100644 --- a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue +++ b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue @@ -51,7 +51,7 @@

{{report.activated_orders}}

{{ Math.ceil((((report.activated_orders / report.total_orders) * 100) * 100) / 100).toFixed(2)}}% - Total: {{report.total_orders}} Orders + Created Orders: {{report.total_orders}} Orders
From 95f52b3a6269c73be819f1beeedf11e84c93ae89 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 2 Oct 2021 15:06:10 +0800 Subject: [PATCH 48/52] customer report --- .../reports/sections/MonthlyReportSectionComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue index f3d3bf36..07bafbb9 100644 --- a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue +++ b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue @@ -51,7 +51,7 @@

{{report.activated_orders}}

{{ Math.ceil((((report.activated_orders / report.total_orders) * 100) * 100) / 100).toFixed(2)}}% - Created Orders: {{report.total_orders}} Orders + Created Orders: {{report.total_orders}}
From c74e2927ada9f1e646d8e335fb57ffcbd934c577 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 2 Oct 2021 15:15:27 +0800 Subject: [PATCH 49/52] customer report --- app/Http/Controllers/Reports/MonthlyReportController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Reports/MonthlyReportController.php b/app/Http/Controllers/Reports/MonthlyReportController.php index abc55895..eb158c62 100644 --- a/app/Http/Controllers/Reports/MonthlyReportController.php +++ b/app/Http/Controllers/Reports/MonthlyReportController.php @@ -6,13 +6,15 @@ use App\Classes\ValueObjects\Constants\HttpStatus; use App\Classes\ValueObjects\Response\ApiResponseObject; use App\Models\Container; use App\Models\Order; +use Carbon\Carbon; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; class MonthlyReportController { public function report(Request $request): JsonResponse { - $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->orderBy('loading_date')->get(); + $month = Carbon::now()->subMonth(); + $containers = Container::whereMonth('loading_date', $month->format('m'))->whereYear('loading_date', '=', '2021')->orderBy('loading_date')->get(); $total = 0; $customers = collect(); @@ -56,7 +58,7 @@ class MonthlyReportController 'packages' => $customers->sum(function($customer){ return $customer['packages']; }), - 'total_orders' => Order::whereMonth('created_at', 9)->whereHas('packingLists')->count() + 'total_orders' => Order::whereMonth('created_at', $month->format('m'))->count() ]]))->handler(); } } From 93c941229866f943dec6ca401a0909a2c8a07c7e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 2 Oct 2021 15:17:22 +0800 Subject: [PATCH 50/52] customer report --- .../reports/sections/MonthlyReportSectionComponent.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue index 07bafbb9..14a08e4a 100644 --- a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue +++ b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue @@ -19,15 +19,15 @@

{{(Math.ceil(report.total_cbm * 1000) / 1000).toFixed(3)}} CBM

- {{ Math.ceil((((report.total_cbm / 700) * 100) * 100) / 100).toFixed(2)}}% - Goal: 700 CBM + {{ Math.ceil((((report.total_cbm / 1000) * 100) * 100) / 100).toFixed(2)}}% + Goal: 1000 CBM
-
+
From 33f152ae9cffbca3ab16ca72221b0da58891ccf6 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 2 Oct 2021 15:22:28 +0800 Subject: [PATCH 51/52] customer report --- app/Http/Controllers/Reports/MonthlyReportController.php | 2 ++ .../reports/sections/MonthlyReportSectionComponent.vue | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Reports/MonthlyReportController.php b/app/Http/Controllers/Reports/MonthlyReportController.php index eb158c62..96836f97 100644 --- a/app/Http/Controllers/Reports/MonthlyReportController.php +++ b/app/Http/Controllers/Reports/MonthlyReportController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Reports; use App\Classes\ValueObjects\Constants\HttpStatus; use App\Classes\ValueObjects\Response\ApiResponseObject; +use App\Models\Company; use App\Models\Container; use App\Models\Order; use Carbon\Carbon; @@ -52,6 +53,7 @@ class MonthlyReportController 'containers' => count($containers), 'activated_orders' => $activeOrders, 'active_customers' => count($customers), + 'new_customers' => Company::whereMonth('created_at', $month->format('m'))->count(), 'total_cbm' => $customers->sum(function($customer){ return $customer['cbm']; }), diff --git a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue index 14a08e4a..2534893e 100644 --- a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue +++ b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue @@ -81,13 +81,15 @@

{{report.active_customers}}

+ {{ Math.ceil((((report.new_customers / report.active_customers) * 100) * 100) / 100).toFixed(2)}}% + New Customers: {{report.new_customers}}
-
+
From 16b35b34b3ea961fd9eb75fd6588fc44411470cb Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 2 Oct 2021 15:24:02 +0800 Subject: [PATCH 52/52] customer report --- .../reports/sections/MonthlyReportSectionComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue index 2534893e..6af42e93 100644 --- a/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue +++ b/resources/assets/vue/components/reports/sections/MonthlyReportSectionComponent.vue @@ -18,7 +18,7 @@
-

{{(Math.ceil(report.total_cbm * 1000) / 1000).toFixed(3)}} CBM

+

{{(Math.ceil(report.total_cbm * 1000) / 1000).toFixed(3)}}

{{ Math.ceil((((report.total_cbm / 1000) * 100) * 100) / 100).toFixed(2)}}% Goal: 1000 CBM