From a545e6bad6271db94e1c2efc53b6b3dce6224526 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 17 Jan 2024 17:19:37 +0800 Subject: [PATCH 1/9] add bill_no in transaction details page --- .../wallets/elements/CustomerWalletTransactionComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/wallets/elements/CustomerWalletTransactionComponent.vue b/resources/assets/vue/components/wallets/elements/CustomerWalletTransactionComponent.vue index cb0bb88f..4f6fba87 100644 --- a/resources/assets/vue/components/wallets/elements/CustomerWalletTransactionComponent.vue +++ b/resources/assets/vue/components/wallets/elements/CustomerWalletTransactionComponent.vue @@ -1,7 +1,7 @@ From 9b9057ea8134d1627c5c1078ea49e49ba4e6bd40 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 21 Jan 2024 10:31:39 +0800 Subject: [PATCH 3/9] Experimental solution (Vue Polling) to solve an AWS API Gateway problem limitation for Laravel Vapor in the event of a emergency rollback to Google --- .../Resources/ListPackingListJobResource.php | 10 +- .../Resources/PackageWithoutOrderResource.php | 41 +++++ ...mentsBillingWithSearchPollingComponent.vue | 90 +++++++++++ ...PaymentsBillingPollingSectionComponent.vue | 141 ++++++++++++++++++ .../views/pages/paymentAndBilling2.blade.php | 8 + routes/web.php | 7 +- 6 files changed, 292 insertions(+), 5 deletions(-) create mode 100644 app/Http/Resources/PackageWithoutOrderResource.php create mode 100644 resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue create mode 100644 resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue create mode 100644 resources/views/pages/paymentAndBilling2.blade.php diff --git a/app/Http/Resources/ListPackingListJobResource.php b/app/Http/Resources/ListPackingListJobResource.php index d260f4b6..348b64a0 100644 --- a/app/Http/Resources/ListPackingListJobResource.php +++ b/app/Http/Resources/ListPackingListJobResource.php @@ -32,10 +32,12 @@ class ListPackingListJobResource extends JsonResource 'transport' => new TransportResource($this->transports()->first()), 'type' => $this->type, 'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListV2Resource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first(), $this->userInfo)), - 'packages' => PackageResource::collection($packages), - $this->mergeWhen($this->owner instanceof Order, [ - 'order' => New OrderResource($this->owner) - ]), + // 'packages' => PackageResource::collection($packages), + // $this->mergeWhen($this->owner instanceof Order, [ + // 'order' => New OrderResource($this->owner) + // ]), + 'packages' => PackageWithoutOrderResource::collection($packages), + $this->mergeWhen($this->owner instanceof Order, [ 'order' => New OrderResource($this->owner) ]), 'shipping_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()), 'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()), // 'suspended_invoices' => TransactionResource::collection($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->get()), diff --git a/app/Http/Resources/PackageWithoutOrderResource.php b/app/Http/Resources/PackageWithoutOrderResource.php new file mode 100644 index 00000000..4400aa44 --- /dev/null +++ b/app/Http/Resources/PackageWithoutOrderResource.php @@ -0,0 +1,41 @@ +packingList->owner instanceof PackingList ? $this->packingList->owner : $this->packingList; + + return [ + 'id' => $this->id, + 'type' => $this->type, + 'description' => $this->description, + 'width' => floatval($this->width), + 'height' => floatval($this->height), + 'length' => floatval($this->length), + 'weight' => $this->weight, + 'quantity' => $this->quantity, + 'cbm' => (($this->width / 100) * ($this->height / 100) * ($this->length / 100)) * $this->quantity, + 'reference' => $this->packingList->reference, + 'status' => $this->status, + // $this->mergeWhen($originalPackingList->owner instanceof Order, [ + // 'order' => New OrderResource($originalPackingList->owner) + // ]), + 'container' => new ContainerResource($originalPackingList->containers()->first()), + 'transport' => new TransportResource($originalPackingList->transports()->first()) + ]; + } +} diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue new file mode 100644 index 00000000..120fc803 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue @@ -0,0 +1,90 @@ + + diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue new file mode 100644 index 00000000..25e4c303 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue @@ -0,0 +1,141 @@ + + diff --git a/resources/views/pages/paymentAndBilling2.blade.php b/resources/views/pages/paymentAndBilling2.blade.php new file mode 100644 index 00000000..cf4f339f --- /dev/null +++ b/resources/views/pages/paymentAndBilling2.blade.php @@ -0,0 +1,8 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+ +
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 9e69dcc5..53c34711 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1247,4 +1247,9 @@ Route::get('fix-payment-status-updated-but-failed-update-invoice', function (Upd echo 'done fix ' . $invoice->owner->owner->reference . '
'; } } -}); \ No newline at end of file +}); + +//A page to monitor Experimental solution (Vue Polling) to solve an AWS API Gateway problem limitation for Laravel Vapor in the event of a emergency rollback to Google +Route::get('/payment-and-billing-2', function () { + return view('pages.paymentAndBilling2'); +})->name('admin.payment-and-billing-2'); From a9e89a45bdf8999dc1d3fe9384648ccdff339712 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 21 Jan 2024 10:53:23 +0800 Subject: [PATCH 4/9] Experimental solution (Vue Polling) to solve an AWS API Gateway problem limitation for Laravel Vapor in the event of a emergency rollback to Google --- app/Classes/Jobs/ListPackingListsJob.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Classes/Jobs/ListPackingListsJob.php b/app/Classes/Jobs/ListPackingListsJob.php index 474531f4..37a970fe 100644 --- a/app/Classes/Jobs/ListPackingListsJob.php +++ b/app/Classes/Jobs/ListPackingListsJob.php @@ -15,6 +15,8 @@ class ListPackingListsJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + public $timeout = 900; + /** @var ListGenericJobObject */ private $listGenericJobObject; From d034a285fc0676730fc6a6f5c283e21a2f3fa15d Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 21 Jan 2024 22:31:16 +0800 Subject: [PATCH 5/9] Vue Polling - Solve a problem where query of packing list with contaienrs and packages data is taking too long to complete --- .../Filters/WithContainersPackages.php | 20 ++ .../ListPackingListsJobProcessor.php | 2 +- .../Resources/ListPackingListJobResource.php | 3 +- .../Resources/PackageWithoutOrderResource.php | 7 +- ...mentsBillingWithSearchPollingComponent.vue | 2 +- .../SingleAdminPaymentsBillingComponent.vue | 322 ++++++++++++++++++ 6 files changed, 348 insertions(+), 8 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/WithContainersPackages.php create mode 100644 resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingComponent.vue diff --git a/app/Classes/General/Eloquent/Filters/WithContainersPackages.php b/app/Classes/General/Eloquent/Filters/WithContainersPackages.php new file mode 100644 index 00000000..5fabff27 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/WithContainersPackages.php @@ -0,0 +1,20 @@ +with(['containers', 'packages']); + } +} diff --git a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php index 4e67f7a1..2a85778e 100644 --- a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php @@ -37,7 +37,7 @@ class ListPackingListsJobProcessor */ public function execute(ListGenericJobObject $listGenericJobObject) { - $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]); + $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]); foreach ($query->items() as &$item) { $item['userInfo'] = $listGenericJobObject->getUserInfo(); } diff --git a/app/Http/Resources/ListPackingListJobResource.php b/app/Http/Resources/ListPackingListJobResource.php index 348b64a0..1e6ad3aa 100644 --- a/app/Http/Resources/ListPackingListJobResource.php +++ b/app/Http/Resources/ListPackingListJobResource.php @@ -36,7 +36,8 @@ class ListPackingListJobResource extends JsonResource // $this->mergeWhen($this->owner instanceof Order, [ // 'order' => New OrderResource($this->owner) // ]), - 'packages' => PackageWithoutOrderResource::collection($packages), + 'container' => new ContainerResource($this->containers->first()), + 'packages' => PackageWithoutOrderResource::collection($this->packages), $this->mergeWhen($this->owner instanceof Order, [ 'order' => New OrderResource($this->owner) ]), 'shipping_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()), 'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()), diff --git a/app/Http/Resources/PackageWithoutOrderResource.php b/app/Http/Resources/PackageWithoutOrderResource.php index 4400aa44..fea5500b 100644 --- a/app/Http/Resources/PackageWithoutOrderResource.php +++ b/app/Http/Resources/PackageWithoutOrderResource.php @@ -16,9 +16,6 @@ class PackageWithoutOrderResource extends JsonResource */ public function toArray($request) { - - $originalPackingList = $this->packingList->owner instanceof PackingList ? $this->packingList->owner : $this->packingList; - return [ 'id' => $this->id, 'type' => $this->type, @@ -34,8 +31,8 @@ class PackageWithoutOrderResource extends JsonResource // $this->mergeWhen($originalPackingList->owner instanceof Order, [ // 'order' => New OrderResource($originalPackingList->owner) // ]), - 'container' => new ContainerResource($originalPackingList->containers()->first()), - 'transport' => new TransportResource($originalPackingList->transports()->first()) + // 'container' => new ContainerResource($originalPackingList->containers()->first()), + // 'transport' => new TransportResource($originalPackingList->transports()->first()) ]; } } diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue index 120fc803..13df803e 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue @@ -42,7 +42,7 @@ --> diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingComponent.vue new file mode 100644 index 00000000..825d9a67 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingComponent.vue @@ -0,0 +1,322 @@ + + From e2b378e1975ca3449f10d0ef2da90544684fa41f Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 21 Jan 2024 22:48:48 +0800 Subject: [PATCH 6/9] Vue Polling - Solve a problem where query of packing list with contaienrs and packages data is taking too long to complete --- app/Http/Resources/ListPackingListJobResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Resources/ListPackingListJobResource.php b/app/Http/Resources/ListPackingListJobResource.php index 1e6ad3aa..6b13be59 100644 --- a/app/Http/Resources/ListPackingListJobResource.php +++ b/app/Http/Resources/ListPackingListJobResource.php @@ -37,7 +37,7 @@ class ListPackingListJobResource extends JsonResource // 'order' => New OrderResource($this->owner) // ]), 'container' => new ContainerResource($this->containers->first()), - 'packages' => PackageWithoutOrderResource::collection($this->packages), + 'packages' => PackageWithoutOrderResource::collection($packages), $this->mergeWhen($this->owner instanceof Order, [ 'order' => New OrderResource($this->owner) ]), 'shipping_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()), 'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()), From 064ee3e41ab2d5d9ee2d5c38fceb3f6a0f009a3f Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 24 Jan 2024 06:50:18 +0800 Subject: [PATCH 7/9] Implement a solution to selectively waived a selected storage invoice --- ...heckStorageInvoiceTransactionProcessor.php | 14 +++++++- ...d_is_waived_to_transactions_logs_table.php | 32 +++++++++++++++++++ ...51_add_is_waived_to_transactions_table.php | 32 +++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2024_01_23_233651_add_is_waived_to_transactions_logs_table.php create mode 100644 database/migrations/2024_01_23_233651_add_is_waived_to_transactions_table.php diff --git a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php index 95089642..bc9adccd 100644 --- a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php @@ -200,6 +200,11 @@ class CheckStorageInvoiceTransactionProcessor $this->createStorageInvoiceTransactionDetails($storageInvoice, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded); } else if($storageInvoice){ + //Additional handling for giving selected storage invoice a waiver + if(isset($storageInvoice->is_waived) && $storageInvoice->is_waived){ + $pricePerCBM = 0; + $price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded; + } //Additional handling for calculation of numberOfDaysExceeded in the event of the storage already paid $paymentStorageTransaction = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::APPROVED)->first(); @@ -216,10 +221,12 @@ class CheckStorageInvoiceTransactionProcessor Log::channel('storage_invoices')->info('Update $transaction->id: '.$transaction->id); Log::channel('storage_invoices')->info('$storageInvoice->status: '.$storageInvoice->status); Log::channel('storage_invoices')->info('price_cbm: '.$price_cbm."-".gettype($price_cbm)); + Log::channel('storage_invoices')->info('amount: '.$amount); + + $proceedToUpdate = false; if(abs($price_cbm - $amount) > $epsilon && $storageInvoice->status !== ApprovalStatus::COMPLETED){ $paymentTransactions = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::PENDING_SUBMISSION)->get(); - if(!$isBackDoorCheck){ if(count($paymentTransactions) > 0){ $this->updatePaymentTransactionViaNonGroupPayment($paymentTransactions); @@ -229,6 +236,11 @@ class CheckStorageInvoiceTransactionProcessor } } + $proceedToUpdate = true; + } + + if($proceedToUpdate || ($pricePerCBM == 0 && $amount != 0)){ + Log::channel('storage_invoices')->info('proceedToUpdate'); $storageInvoice = $this->updateStorageInvoiceTransaction($storageInvoice, $price_cbm); $invoiceTransactionDetails = $storageInvoice->transactionDetails()->first(); $this->updateStorageInvoiceTransactionDetails($invoiceTransactionDetails, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded); diff --git a/database/migrations/2024_01_23_233651_add_is_waived_to_transactions_logs_table.php b/database/migrations/2024_01_23_233651_add_is_waived_to_transactions_logs_table.php new file mode 100644 index 00000000..6755dcef --- /dev/null +++ b/database/migrations/2024_01_23_233651_add_is_waived_to_transactions_logs_table.php @@ -0,0 +1,32 @@ +boolean('is_waived')->nullable()->after('status')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('transaction_logs', function (Blueprint $table) { + $table->dropColumn('is_waived'); + }); + } +} diff --git a/database/migrations/2024_01_23_233651_add_is_waived_to_transactions_table.php b/database/migrations/2024_01_23_233651_add_is_waived_to_transactions_table.php new file mode 100644 index 00000000..30a5e738 --- /dev/null +++ b/database/migrations/2024_01_23_233651_add_is_waived_to_transactions_table.php @@ -0,0 +1,32 @@ +boolean('is_waived')->nullable()->after('status')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('transactions', function (Blueprint $table) { + $table->dropColumn('is_waived'); + }); + } +} From b6c9c8843d183fffa5cdad66f417a118038c6cea Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 26 Jan 2024 02:19:31 +0800 Subject: [PATCH 8/9] Vue Polling - Solve a problem where query of packing list with contaienrs and packages data is taking too long to complete --- .../PackingLists/Processors/ListPackingListsJobProcessor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php index 2a85778e..9ad8a7e7 100644 --- a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php @@ -37,7 +37,9 @@ class ListPackingListsJobProcessor */ public function execute(ListGenericJobObject $listGenericJobObject) { - $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]); + // $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]); + $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]); + Log:info(json_encode($query)); foreach ($query->items() as &$item) { $item['userInfo'] = $listGenericJobObject->getUserInfo(); } From 8fc3ac1b55665acd5b0bc358cdb96cb71e6b3f50 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 26 Jan 2024 03:18:58 +0800 Subject: [PATCH 9/9] Vue Polling - Solve a problem where query of packing list with contaienrs and packages data is taking too long to complete --- .../PackingLists/Processors/ListPackingListsJobProcessor.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php index 9ad8a7e7..2f3a5eed 100644 --- a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php @@ -38,8 +38,9 @@ class ListPackingListsJobProcessor public function execute(ListGenericJobObject $listGenericJobObject) { // $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]); - $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]); - Log:info(json_encode($query)); + + $query = $this->listsPackingLists->execute(array_merge($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true])); + foreach ($query->items() as &$item) { $item['userInfo'] = $listGenericJobObject->getUserInfo(); }