From 5c9fd6e2a65fa5bab35cfb58db80a0d10ce049c3 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 20 Dec 2023 20:52:24 +0800 Subject: [PATCH 01/89] Emergency fix problem with group payment (reported by Eileen) --- .../Processors/CallbackBillplzProcessor.php | 2 +- .../CreatePaymentTransactionProcessor.php | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php index f8dfc119..e4ba38bf 100644 --- a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php +++ b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php @@ -82,7 +82,7 @@ class CallbackBillplzProcessor foreach ($group->groupTransactions as $groupTransaction) { $invoice = $groupTransaction->transaction; - $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null); + $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false); if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ $pL = $invoice->owner; diff --git a/app/Classes/Modules/Transactions/Processors/CreatePaymentTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreatePaymentTransactionProcessor.php index 8f589de0..ad5e79ab 100644 --- a/app/Classes/Modules/Transactions/Processors/CreatePaymentTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreatePaymentTransactionProcessor.php @@ -85,7 +85,7 @@ class CreatePaymentTransactionProcessor /** * @throws MalformedRequestException */ - public function execute(Transaction $invoice, $payment_method, $bank_code) + public function execute(Transaction $invoice, $payment_method, $bank_code, $run = true) { $amount = $invoice->amount; Log::info($invoice->owner); @@ -127,22 +127,26 @@ class CreatePaymentTransactionProcessor $this->updatesWalletBalance->execute($wallet, ($amount * -1)); - // $packingList = $invoice->owner; - // $order = $packingList->owner; - // $packingList->status = ApprovalStatus::APPROVED; - // $packingList->save(); + if($run) + { + $packingList = $invoice->owner; + $order = $packingList->owner; + $packingList->status = ApprovalStatus::APPROVED; + $packingList->save(); - // if(app()->environment('production')){ - // $this->updateDoFromVTPortalProcessor->execute($packingList); - // $this->updateDoFromYDPortalProcessor->execute($packingList); - // } + if(app()->environment('production')){ + $this->updateDoFromVTPortalProcessor->execute($packingList); + $this->updateDoFromYDPortalProcessor->execute($packingList); + } + } // later use this variabke to create a approved payment transaction $approvalStatus = ApprovalStatus::APPROVED; // update invoice to completed - // $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED); - + if($run){ + $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED); + } } else { $payment_method = PaymentMethodType::CASH; From b4eca67a2ff7735640d3e9c19f824b4f432047e7 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 20 Dec 2023 23:58:56 +0800 Subject: [PATCH 02/89] Emergency fix problem with group payment (reported by Eileen) --- .../Processors/CallbackBillplzProcessor.php | 62 ++---------- .../UpdateDoFromYDPortalProcessor.php | 1 + .../ControllersLogic/CreateGroupsLogic.php | 21 ++++- .../CreatePaymentTransactionLogic.php | 19 +++- .../ReleaseGoodsToCustomerProcessor.php | 94 +++++++++++++++++++ .../Commands/FixGroupPaymentProblem.php | 85 +++++++++++++++++ 6 files changed, 222 insertions(+), 60 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Processors/ReleaseGoodsToCustomerProcessor.php create mode 100644 app/Console/Commands/FixGroupPaymentProblem.php diff --git a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php index e4ba38bf..79b81452 100644 --- a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php +++ b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php @@ -6,10 +6,9 @@ use Illuminate\Http\Request; use App\Models\Wallet; use App\Models\Group; use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor; -use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionProcessor; +use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance; use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor; @@ -33,8 +32,8 @@ class CallbackBillplzProcessor /** @var CreatePaymentTransactionProcessor */ private $createPaymentTransactionProcessor; - /** @var CreateStorageInvoiceDocTransactionProcessor */ - private $ceateStorageInvoiceDocTransactionProcessor; + /** @var ReleaseGoodsToCustomerProcessor */ + private $releaseGoodsToCustomerProcessor; /** * CreateUserProcessor constructor. @@ -43,16 +42,16 @@ class CallbackBillplzProcessor * @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor * @param UpdatesWalletBalance $updatesWalletBalance * @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor - * @param CreateStorageInvoiceDocTransactionProcessor $ceateStorageInvoiceDocTransactionProcessor + * @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor */ - public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, CreateStorageInvoiceDocTransactionProcessor $ceateStorageInvoiceDocTransactionProcessor) + public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor) { $this->updatesTransactionStatus = $updatesTransactionStatus; $this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor; $this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor; $this->updatesWalletBalance = $updatesWalletBalance; $this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor; - $this->ceateStorageInvoiceDocTransactionProcessor = $ceateStorageInvoiceDocTransactionProcessor; + $this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor; } @@ -86,7 +85,7 @@ class CallbackBillplzProcessor if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ $pL = $invoice->owner; - $this->processPackingListAndInvoice($pL, $invoice); + $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); } } @@ -96,7 +95,7 @@ class CallbackBillplzProcessor } if (!$transaction->owner instanceof Wallet) { - $this->processPackingListAndInvoice($packingList, $invoice); + $this->releaseGoodsToCustomerProcessor->execute($packingList, $invoice); } return true; @@ -126,49 +125,4 @@ class CallbackBillplzProcessor } return true; } - - private function processPackingListAndInvoice($packingList, $invoice = null){ - $result = false; - $totalInvoicesAmountPaid = 0.00; - $totalInvoicesAmount = 0.00; - $invoiceTransactions = $packingList->transactions()->where('status', [ApprovalStatus::APPROVED])->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get(); - - //Part 1: Process each single invoice type and get the total of all invoices - foreach($invoiceTransactions as $invoiceTransaction){ - - $totalInvoiceAmountPaid = $invoiceTransaction->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount'); - if ($invoice && $invoice->type == $invoiceTransaction->type) { - if(($invoice->amount - $totalInvoiceAmountPaid) < 0.01){ - $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED); - - if($invoice->type == TransactionType::STORAGE_INVOICE){ - $this->ceateStorageInvoiceDocTransactionProcessor->execute($packingList); - } - } - } - - $totalInvoicesAmount = $totalInvoicesAmount + $invoiceTransaction->amount; - $totalInvoicesAmountPaid = $totalInvoicesAmountPaid + $totalInvoiceAmountPaid; - } - - Log::channel('storage_invoices')->info('Total invoice amount paid 1: '.$totalInvoicesAmount); //cief todo: to be removed - Log::channel('storage_invoices')->info('Total invoice amount paid 2: '.$totalInvoicesAmountPaid); //cief todo: to be removed - - //Part 2: Based on the collected info for all the total of all invoices - if (($totalInvoicesAmount - $totalInvoicesAmountPaid) < 0.01) { - Log::channel('storage_invoices')->info('Total invoice amount paid 3: '.$totalInvoicesAmountPaid); //cief todo: to be removed - - $packingList->status = ApprovalStatus::APPROVED; - $packingList->save(); - - if (app()->environment('production')) { - $this->updateDoFromVTPortalProcessor->execute($packingList); - $this->updateDoFromYDPortalProcessor->execute($packingList); - } - - $result = true; - } - - return $result; - } } diff --git a/app/Classes/Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php b/app/Classes/Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php index 2273e10b..a035c053 100644 --- a/app/Classes/Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php +++ b/app/Classes/Modules/Orders/Processors/UpdateDoFromYDPortalProcessor.php @@ -38,6 +38,7 @@ class UpdateDoFromYDPortalProcessor */ public function execute(PackingList $packingList) { Log::info('Trying to Call UpdateDoFromYDPortalProcessor'); + Log::channel('storage_invoices')->info('UpdateDoFromYDPortalProcessor: '.json_encode($packingList)); if(!app()->environment(['production'])){ return; diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php index 49a59f05..c064cc4e 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php @@ -21,6 +21,8 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Models\GroupTransaction; use App\Http\Resources\WalletTransactionResource; use App\Models\Wallet; +use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor; + class CreateGroupsLogic extends AbstractControllerLogic { @@ -55,13 +57,18 @@ class CreateGroupsLogic extends AbstractControllerLogic /** @var CreatesGroup */ private $createsGroup; + /** @var ReleaseGoodsToCustomerProcessor */ + private $releaseGoodsToCustomerProcessor; + + public function __construct( - FetchesTransaction $fetchesTransaction, - GeneratesTransactionBillNumber $generatesTransactionBillNumber, + FetchesTransaction $fetchesTransaction, + GeneratesTransactionBillNumber $generatesTransactionBillNumber, FetchesCompanyModule $fetchesCompanyModule, CreateWalletTopUpTransactionProcessor $createWalletTopUpTransactionProcessor, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, - CreatesGroup $createsGroup + CreatesGroup $createsGroup, + ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor ) { $this->fetchesTransaction = $fetchesTransaction; @@ -70,6 +77,7 @@ class CreateGroupsLogic extends AbstractControllerLogic $this->createWalletTopUpTransactionProcessor = $createWalletTopUpTransactionProcessor; $this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor; $this->createsGroup = $createsGroup; + $this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor; } public function logic(Request $request) : JsonResponse @@ -146,7 +154,12 @@ class CreateGroupsLogic extends AbstractControllerLogic foreach ($invoices as $invoice) { if ($payment_method == PaymentMethodType::WALLET) { - $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, $request->input('bank_code')); + $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, $request->input('bank_code'), false); + + if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ + $pL = $invoice->owner; + $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); + } } $issuer = $invoice->issuer; diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php index ae10403a..ab5fa2a6 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php @@ -10,6 +10,8 @@ use App\Http\Resources\TransactionResource; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor; +use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor; +use App\Classes\ValueObjects\Constants\ApprovalStatus; class CreatePaymentTransactionLogic extends AbstractControllerLogic { @@ -30,13 +32,18 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic /** @var CreatePaymentTransactionProcessor */ private $createPaymentTransactionProcessor; + /** @var ReleaseGoodsToCustomerProcessor */ + private $releaseGoodsToCustomerProcessor; + public function __construct( FetchesTransaction $fetchesTransaction, - CreatePaymentTransactionProcessor $createPaymentTransactionProcessor + CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, + ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor ) { $this->fetchesTransaction = $fetchesTransaction; $this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor; + $this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor; } public function logic(Request $request) : JsonResponse @@ -45,7 +52,12 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic $invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->input('transaction_id')]); - $payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code')); + $payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code'), false); + + if($payment_transaction && $payment_transaction->status == ApprovalStatus::APPROVED){ + $pL = $invoice_transaction->owner; + $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice_transaction); + } //cief todo: at exchange there is a transition step - starts // if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){ @@ -63,4 +75,7 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic return $this->resourceResponse(new TransactionResource($payment_transaction)); } + + + } diff --git a/app/Classes/Modules/Transactions/Processors/ReleaseGoodsToCustomerProcessor.php b/app/Classes/Modules/Transactions/Processors/ReleaseGoodsToCustomerProcessor.php new file mode 100644 index 00000000..766947c6 --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/ReleaseGoodsToCustomerProcessor.php @@ -0,0 +1,94 @@ +updatesTransactionStatus = $updatesTransactionStatus; + $this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor; + $this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor; + $this->createStorageInvoiceDocTransactionProcessor = $createStorageInvoiceDocTransactionProcessor; + } + + + /** + * @param $packingList + * @param $invoice + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute($packingList, $invoice = null) + { + $result = false; + $totalInvoicesAmountPaid = 0.00; + $totalInvoicesAmount = 0.00; + $invoiceTransactions = $packingList->transactions()->where('status', [ApprovalStatus::APPROVED])->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get(); + + //Part 1: Process each single invoice type and get the total of all invoices + foreach($invoiceTransactions as $invoiceTransaction){ + + $totalInvoiceAmountPaid = $invoiceTransaction->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount'); + if ($invoice && $invoice->type == $invoiceTransaction->type) { + if(($invoice->amount - $totalInvoiceAmountPaid) < 0.01){ + $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED); + + if($invoice->type == TransactionType::STORAGE_INVOICE){ + $this->createStorageInvoiceDocTransactionProcessor->execute($packingList); + } + } + } + + $totalInvoicesAmount = $totalInvoicesAmount + $invoiceTransaction->amount; + $totalInvoicesAmountPaid = $totalInvoicesAmountPaid + $totalInvoiceAmountPaid; + } + + Log::channel('storage_invoices')->info('Total invoice amount paid 1: '.$totalInvoicesAmount); //cief todo: to be removed + Log::channel('storage_invoices')->info('Total invoice amount paid 2: '.$totalInvoicesAmountPaid); //cief todo: to be removed + + //Part 2: Based on the collected info for all the total of all invoices + if (($totalInvoicesAmount - $totalInvoicesAmountPaid) < 0.01 && $totalInvoicesAmountPaid > 0.01) { + Log::channel('storage_invoices')->info('Total invoice amount paid 3: '.$totalInvoicesAmountPaid); //cief todo: to be removed + + $packingList->status = ApprovalStatus::APPROVED; + $packingList->save(); + + if (app()->environment('production')) { + $this->updateDoFromVTPortalProcessor->execute($packingList); + $this->updateDoFromYDPortalProcessor->execute($packingList); + } + + $result = true; + } + + return $result; + } +} diff --git a/app/Console/Commands/FixGroupPaymentProblem.php b/app/Console/Commands/FixGroupPaymentProblem.php new file mode 100644 index 00000000..50aafba2 --- /dev/null +++ b/app/Console/Commands/FixGroupPaymentProblem.php @@ -0,0 +1,85 @@ +listsGroups = $listsGroups; + $this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor; + } + + + /** + * Execute the console command. + * + * @return int + */ + public function handle() + { + ini_set('memory_limit', '-1'); + + $this->info(Carbon::now() . ': Start data patch.'); + $start = new Carbon(); + + $newfilters['id'] = 325; + $groups = $this->listsGroups->execute($newfilters); + + foreach ($groups as $group){ + $this->info('CheckForStorageInvoiceByTransactions group: '.json_encode($group)); + if ($group) { + foreach ($group->groupTransactions as $groupTransaction) { + $invoice = $groupTransaction->transaction; + $this->info('CheckForStorageInvoiceByTransactions group: '.json_encode($invoice)); + //$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null); + + //if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ + $pL = $invoice->owner; + $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); + //} + } + // $group->status = $status; + // $group->save(); + } + } + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + + $this->info(Carbon::now() . ': Done data patch. ElapsedTime: ' . $elapsedTime . '.'); + } +} From 6f36c4b7ee775285fe009456f12552185f798edf Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 21 Dec 2023 02:17:04 +0800 Subject: [PATCH 03/89] Emergency fix problem with group payment (reported by Eileen) --- .../Commands/FixGroupPaymentProblem.php | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/app/Console/Commands/FixGroupPaymentProblem.php b/app/Console/Commands/FixGroupPaymentProblem.php index 50aafba2..5330a761 100644 --- a/app/Console/Commands/FixGroupPaymentProblem.php +++ b/app/Console/Commands/FixGroupPaymentProblem.php @@ -3,7 +3,7 @@ namespace App\Console\Commands; -use App\Classes\Modules\Transactions\Services\ListsGroups; +use App\Classes\Modules\Transactions\Services\FetchesGroup; use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor; use Carbon\Carbon; use Illuminate\Console\Command; @@ -24,8 +24,8 @@ class FixGroupPaymentProblem extends Command */ protected $description = 'This is a one time data patch for a problem result from Storage Invoice Implementation'; - /** @var ListsGroups */ - private $listsGroups; + /** @var FetchesGroup */ + private $fetchesGroup; /** @var ReleaseGoodsToCustomerProcessor */ private $releaseGoodsToCustomerProcessor; @@ -36,10 +36,10 @@ class FixGroupPaymentProblem extends Command * * @return void */ - public function __construct(ListsGroups $listsGroups, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor) + public function __construct(FetchesGroup $fetchesGroup, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor) { parent::__construct(); - $this->listsGroups = $listsGroups; + $this->fetchesGroup = $fetchesGroup; $this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor; } @@ -56,27 +56,25 @@ class FixGroupPaymentProblem extends Command $this->info(Carbon::now() . ': Start data patch.'); $start = new Carbon(); - $newfilters['id'] = 325; - $groups = $this->listsGroups->execute($newfilters); + $group = $this->fetchesGroup->execute(['id' => 325]); - foreach ($groups as $group){ - $this->info('CheckForStorageInvoiceByTransactions group: '.json_encode($group)); - if ($group) { - foreach ($group->groupTransactions as $groupTransaction) { - $invoice = $groupTransaction->transaction; - $this->info('CheckForStorageInvoiceByTransactions group: '.json_encode($invoice)); - //$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null); + $this->info('FixGroupPaymentProblem group: '.json_encode($group)); + if ($group) { + foreach ($group->groupTransactions as $groupTransaction) { + $invoice = $groupTransaction->transaction; + $this->info('FixGroupPaymentProblem group: '.json_encode($invoice)); + //$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null); - //if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ - $pL = $invoice->owner; - $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); - //} - } - // $group->status = $status; - // $group->save(); + //if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ + $pL = $invoice->owner; + $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); + //} } + // $group->status = $status; + // $group->save(); } + $end = new Carbon(); $elapsedTime = $start->diff($end)->format('%H:%I:%S'); From 6427e2996f73d6c0d206fa5d980357cd69df9bce Mon Sep 17 00:00:00 2001 From: Steve Ng Date: Wed, 3 Jan 2024 09:05:07 +0800 Subject: [PATCH 04/89] change posting date to invoice date for shipping portal when export invoice to autocount --- app/Http/Resources/MappableTransactionResource.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Resources/MappableTransactionResource.php b/app/Http/Resources/MappableTransactionResource.php index 2b1486da..447e6150 100644 --- a/app/Http/Resources/MappableTransactionResource.php +++ b/app/Http/Resources/MappableTransactionResource.php @@ -37,6 +37,7 @@ class MappableTransactionResource extends JsonResource 'owner_type' => Transaction::class, 'owner_id'=> $this->id, 'owner_reference'=> $reference, + 'created_at'=> $this->created_at, // invoice date ]; } } From 894481591d46e0224742a8128738fa11d28c9439 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 4 Jan 2024 13:52:11 +0800 Subject: [PATCH 05/89] Proof of concept - Vue Polling - Performance Improvement and tweaking for better user experience --- .../vue/components/general/elements/ListPollingComponent.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/assets/vue/components/general/elements/ListPollingComponent.vue b/resources/assets/vue/components/general/elements/ListPollingComponent.vue index 5d34d374..e755779a 100644 --- a/resources/assets/vue/components/general/elements/ListPollingComponent.vue +++ b/resources/assets/vue/components/general/elements/ListPollingComponent.vue @@ -76,6 +76,7 @@ filters: this.options, pollingInterval: null, isPolling: false, + isFetchingResult: false, isLoading: false, } }, @@ -124,6 +125,7 @@ this.isLoading = false; }, errorHandler(error){ + this.isFetchingResult = false; this.isPolling = false; }, startPolling(jobId, maxAttempts = 8) { @@ -135,7 +137,7 @@ }; const pollJobResult = () => { - if (this.isPolling) { + if (this.isPolling || this.isFetchingResult) { return; } this.isPolling = true; @@ -187,6 +189,7 @@ }, fetchJobResult(jobId, isLastAttempt = false) { // console.log('fetchJobResult: ', jobId); + this.isFetchingResult = true; try { let anotherEndpoint = route('api.job.fetch', jobId); if(isLastAttempt){ From 7a2ed92147d56d35d15fa4544aa81b0c65b40448 Mon Sep 17 00:00:00 2001 From: Steve Ng Date: Fri, 5 Jan 2024 11:10:42 +0800 Subject: [PATCH 06/89] change posting date to invoice date for shipping portal when export invoice to autocount --- app/Http/Resources/MappableTransactionWithDetailsResource.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Resources/MappableTransactionWithDetailsResource.php b/app/Http/Resources/MappableTransactionWithDetailsResource.php index 8622d85b..be8cac20 100644 --- a/app/Http/Resources/MappableTransactionWithDetailsResource.php +++ b/app/Http/Resources/MappableTransactionWithDetailsResource.php @@ -33,10 +33,12 @@ class MappableTransactionWithDetailsResource extends JsonResource $order = $this->owner->owner->owner; $data['order_reference'] = $order->reference; $data['debtor_code'] = $order->companyModule->company->debtor; + $data['created_at'] = $this->owner->created_at; // invoice date } elseif (in_array($this->type, [TransactionType::GROUP_PAYMENT, TransactionType::TOP_UP])) { $connection = $this->owner->owner->inviters()->withPivot('invitee_reference')->first(); $data['marking'] = $connection ? $connection->pivot->invitee_reference : ''; $data['bill_no'] = $this->bill_no; + $data['created_at'] = $this->created_at; } else { $payments = $this->transactions() ->payments()->where('status', ApprovalStatus::APPROVED) @@ -54,6 +56,7 @@ class MappableTransactionWithDetailsResource extends JsonResource 'type' => $payment->type, 'marking' => null, 'amount' => $payment->amount, + 'created_at' => $this->created_at ]; })->toArray(); } else { From ee69f9123cb232ba3f4b8322b7f12d9619088498 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 6 Jan 2024 05:05:59 +0800 Subject: [PATCH 07/89] Fix attempt on storage invoice pdf not able to be downloaded by user --- ...eStorageInvoiceDocTransactionProcessor.php | 4 +-- .../Commands/FixGroupPaymentProblem.php | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionProcessor.php index d46f5661..574c34b2 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionProcessor.php @@ -46,7 +46,7 @@ class CreateStorageInvoiceDocTransactionProcessor /** * @throws MalformedRequestException */ - public function execute(PackingList $packingList) + public function execute(PackingList $packingList, bool $isOverwrite = false) { /** @var Transaction $invoice_transaction */ $invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED])->first(); @@ -64,7 +64,7 @@ class CreateStorageInvoiceDocTransactionProcessor ); $invouce_transaction_document = $invoice_transaction->documents()->where('document_type', DocumentType::STORAGE_INVOICE)->first(); - if(!$invouce_transaction_document){ + if(!$invouce_transaction_document || $isOverwrite){ /** @var Document $document */ $document = $this->createsDocument->execute($invoice_transaction, $document_object); diff --git a/app/Console/Commands/FixGroupPaymentProblem.php b/app/Console/Commands/FixGroupPaymentProblem.php index 5330a761..c1bcfb9f 100644 --- a/app/Console/Commands/FixGroupPaymentProblem.php +++ b/app/Console/Commands/FixGroupPaymentProblem.php @@ -4,7 +4,9 @@ namespace App\Console\Commands; use App\Classes\Modules\Transactions\Services\FetchesGroup; +use App\Classes\Modules\Orders\Services\FetchesOrder; use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor; +use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionProcessor; use Carbon\Carbon; use Illuminate\Console\Command; @@ -30,17 +32,24 @@ class FixGroupPaymentProblem extends Command /** @var ReleaseGoodsToCustomerProcessor */ private $releaseGoodsToCustomerProcessor; + /** @var FetchesOrder */ + private $fetchesOrder; + + /** @var CreateStorageInvoiceDocTransactionProcessor */ + private $createStorageInvoiceDocTransactionProcessor; /** * Create a new command instance. * * @return void */ - public function __construct(FetchesGroup $fetchesGroup, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor) + public function __construct(FetchesGroup $fetchesGroup, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor, FetchesOrder $fetchesOrder, CreateStorageInvoiceDocTransactionProcessor $createStorageInvoiceDocTransactionProcessor) { parent::__construct(); $this->fetchesGroup = $fetchesGroup; $this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor; + $this->fetchesOrder = $fetchesOrder; + $this->createStorageInvoiceDocTransactionProcessor = $createStorageInvoiceDocTransactionProcessor; } @@ -56,22 +65,25 @@ class FixGroupPaymentProblem extends Command $this->info(Carbon::now() . ': Start data patch.'); $start = new Carbon(); + /* $group = $this->fetchesGroup->execute(['id' => 325]); - $this->info('FixGroupPaymentProblem group: '.json_encode($group)); if ($group) { foreach ($group->groupTransactions as $groupTransaction) { $invoice = $groupTransaction->transaction; $this->info('FixGroupPaymentProblem group: '.json_encode($invoice)); - //$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null); - - //if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ - $pL = $invoice->owner; - $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); - //} + $pL = $invoice->owner; + $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); } - // $group->status = $status; - // $group->save(); + } + */ + + $order = $this->fetchesOrder->execute(['reference' => '729251424']); + $packingLists = $order->destinationWarehousePackages; + + foreach ($packingLists as $packingList){ + $this->createStorageInvoiceDocTransactionProcessor->execute($packingList, false); + dd(json_encode($packingList)); } From 51a96812fd0d742d473e3c1230ac2b6430b76519 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 6 Jan 2024 05:10:50 +0800 Subject: [PATCH 08/89] Fix attempt on storage invoice pdf not able to be downloaded by user --- app/Console/Commands/FixGroupPaymentProblem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/FixGroupPaymentProblem.php b/app/Console/Commands/FixGroupPaymentProblem.php index c1bcfb9f..df759d33 100644 --- a/app/Console/Commands/FixGroupPaymentProblem.php +++ b/app/Console/Commands/FixGroupPaymentProblem.php @@ -82,7 +82,7 @@ class FixGroupPaymentProblem extends Command $packingLists = $order->destinationWarehousePackages; foreach ($packingLists as $packingList){ - $this->createStorageInvoiceDocTransactionProcessor->execute($packingList, false); + $this->createStorageInvoiceDocTransactionProcessor->execute($packingList, true); dd(json_encode($packingList)); } From 81e04e9cb07a93868a3d291eb59a3a816e4d61ab Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 6 Jan 2024 05:52:26 +0800 Subject: [PATCH 09/89] Fix attempt on storage invoice pdf not able to be downloaded by user --- ...orageInvoiceDocTransactionFixProcessor.php | 79 +++++++++++++++++++ ...eStorageInvoiceDocTransactionProcessor.php | 4 +- .../Commands/FixGroupPaymentProblem.php | 6 +- 3 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php diff --git a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php new file mode 100644 index 00000000..95a70932 --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php @@ -0,0 +1,79 @@ +updatesTransactionStatus = $updatesTransactionStatus; + $this->createsDocument = $createsDocument; + $this->createsFiles = $createsFiles; + } + + + /** + * @throws MalformedRequestException + */ + public function execute(PackingList $packingList) + { + /** @var Transaction $invoice_transaction */ + $invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED])->first(); + + // $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED); + + $transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]); + + $document_object = new DocumentObject( + DocumentType::STORAGE_INVOICE, + [chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))], + '', + ApprovalStatus::COMPLETED, + 'storage_invoice' + ); + + $invouce_transaction_document = $invoice_transaction->documents()->where('document_type', DocumentType::STORAGE_INVOICE)->first(); + // if(!$invouce_transaction_document){ + /** @var Document $document */ + $document = $this->createsDocument->execute($invoice_transaction, $document_object); + + $this->createsFiles->execute($document, $document_object); + $user = $packingList->owner->companyModule->employees()->first(); + // if(app()->environment(['production'])) { + // $user->notify(new InvoiceIssuedEmail($user, $packingList)); + // } + // } + } + +} diff --git a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionProcessor.php index 574c34b2..d46f5661 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionProcessor.php @@ -46,7 +46,7 @@ class CreateStorageInvoiceDocTransactionProcessor /** * @throws MalformedRequestException */ - public function execute(PackingList $packingList, bool $isOverwrite = false) + public function execute(PackingList $packingList) { /** @var Transaction $invoice_transaction */ $invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED])->first(); @@ -64,7 +64,7 @@ class CreateStorageInvoiceDocTransactionProcessor ); $invouce_transaction_document = $invoice_transaction->documents()->where('document_type', DocumentType::STORAGE_INVOICE)->first(); - if(!$invouce_transaction_document || $isOverwrite){ + if(!$invouce_transaction_document){ /** @var Document $document */ $document = $this->createsDocument->execute($invoice_transaction, $document_object); diff --git a/app/Console/Commands/FixGroupPaymentProblem.php b/app/Console/Commands/FixGroupPaymentProblem.php index df759d33..fee8fb35 100644 --- a/app/Console/Commands/FixGroupPaymentProblem.php +++ b/app/Console/Commands/FixGroupPaymentProblem.php @@ -6,7 +6,7 @@ namespace App\Console\Commands; use App\Classes\Modules\Transactions\Services\FetchesGroup; use App\Classes\Modules\Orders\Services\FetchesOrder; use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor; -use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionProcessor; +use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionFixProcessor; use Carbon\Carbon; use Illuminate\Console\Command; @@ -35,7 +35,7 @@ class FixGroupPaymentProblem extends Command /** @var FetchesOrder */ private $fetchesOrder; - /** @var CreateStorageInvoiceDocTransactionProcessor */ + /** @var CreateStorageInvoiceDocTransactionFixProcessor */ private $createStorageInvoiceDocTransactionProcessor; /** @@ -43,7 +43,7 @@ class FixGroupPaymentProblem extends Command * * @return void */ - public function __construct(FetchesGroup $fetchesGroup, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor, FetchesOrder $fetchesOrder, CreateStorageInvoiceDocTransactionProcessor $createStorageInvoiceDocTransactionProcessor) + public function __construct(FetchesGroup $fetchesGroup, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor, FetchesOrder $fetchesOrder, CreateStorageInvoiceDocTransactionFixProcessor $createStorageInvoiceDocTransactionProcessor) { parent::__construct(); $this->fetchesGroup = $fetchesGroup; From 3b2d06ed8f522b713ff39a67daf346c60384fdd3 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 6 Jan 2024 05:52:55 +0800 Subject: [PATCH 10/89] Fix attempt on storage invoice pdf not able to be downloaded by user --- .../CreateStorageInvoiceDocTransactionFixProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php index 95a70932..e5656f6f 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php @@ -69,7 +69,7 @@ class CreateStorageInvoiceDocTransactionFixProcessor $document = $this->createsDocument->execute($invoice_transaction, $document_object); $this->createsFiles->execute($document, $document_object); - $user = $packingList->owner->companyModule->employees()->first(); + // $user = $packingList->owner->companyModule->employees()->first(); // if(app()->environment(['production'])) { // $user->notify(new InvoiceIssuedEmail($user, $packingList)); // } From 9ceba30680433b54dcbaf318fc0b9098376f509f Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 6 Jan 2024 05:53:59 +0800 Subject: [PATCH 11/89] Fix attempt on storage invoice pdf not able to be downloaded by user --- .../CreateStorageInvoiceDocTransactionFixProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php index e5656f6f..f019209e 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateStorageInvoiceDocTransactionFixProcessor.php @@ -63,7 +63,7 @@ class CreateStorageInvoiceDocTransactionFixProcessor 'storage_invoice' ); - $invouce_transaction_document = $invoice_transaction->documents()->where('document_type', DocumentType::STORAGE_INVOICE)->first(); + // $invouce_transaction_document = $invoice_transaction->documents()->where('document_type', DocumentType::STORAGE_INVOICE)->first(); // if(!$invouce_transaction_document){ /** @var Document $document */ $document = $this->createsDocument->execute($invoice_transaction, $document_object); From 1956a4095da40d7910d27ad6d46efc0f8430dfa8 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 8 Jan 2024 17:49:42 +0800 Subject: [PATCH 12/89] Proof of concept - Vue Polling - Performance Improvement and tweaking for better user experience --- .../vue/components/general/elements/ListPollingComponent.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/assets/vue/components/general/elements/ListPollingComponent.vue b/resources/assets/vue/components/general/elements/ListPollingComponent.vue index e755779a..03c58088 100644 --- a/resources/assets/vue/components/general/elements/ListPollingComponent.vue +++ b/resources/assets/vue/components/general/elements/ListPollingComponent.vue @@ -170,6 +170,7 @@ clearInterval(this.pollingInterval); this.pollingInterval = null; this.isPolling = false; + this.isFetchingResult = false; }, submitJob(url){ try { From f0cb7828c3cbf23bd7c8131bad3b81c67f56ee65 Mon Sep 17 00:00:00 2001 From: Steve Ng Date: Wed, 10 Jan 2024 19:10:21 +0800 Subject: [PATCH 13/89] invoice date for shipping portal when export invoice to autocount --- app/Http/Resources/MappableTransactionWithDetailsResource.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Resources/MappableTransactionWithDetailsResource.php b/app/Http/Resources/MappableTransactionWithDetailsResource.php index be8cac20..bf1fcf1d 100644 --- a/app/Http/Resources/MappableTransactionWithDetailsResource.php +++ b/app/Http/Resources/MappableTransactionWithDetailsResource.php @@ -27,6 +27,7 @@ class MappableTransactionWithDetailsResource extends JsonResource 'order_reference' => null, 'bill_no' => null, 'marking' => null, + 'created_at' => null ]; if ($this->type === TransactionType::PAYMENT) { @@ -64,6 +65,7 @@ class MappableTransactionWithDetailsResource extends JsonResource $data['amount'] = 'Transaction Type not allowed'; $data['transaction_type'] = $this->type; $data['payment_transactions'] = null; + $data['created_at'] = null; } } From 7e754a9c7b8dd1192706bfefeacc12b0bb34d2c5 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 11 Jan 2024 17:37:01 +0800 Subject: [PATCH 14/89] add search postcode --- .../General/Eloquent/Filters/PostcodeLike.php | 20 +++++ .../elements/ListPostcodeComponent.vue | 6 +- .../elements/PostcodeSectionComponent.vue | 79 +++++++++++++++++++ resources/views/pages/settings.blade.php | 10 +-- 4 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/PostcodeLike.php create mode 100644 resources/assets/vue/components/settings/elements/PostcodeSectionComponent.vue diff --git a/app/Classes/General/Eloquent/Filters/PostcodeLike.php b/app/Classes/General/Eloquent/Filters/PostcodeLike.php new file mode 100644 index 00000000..b8873d43 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/PostcodeLike.php @@ -0,0 +1,20 @@ +where('postcode', 'LIKE', '%'.$value.'%'); + } + +} \ No newline at end of file diff --git a/resources/assets/vue/components/settings/elements/ListPostcodeComponent.vue b/resources/assets/vue/components/settings/elements/ListPostcodeComponent.vue index fd9df462..0a6c8ab9 100644 --- a/resources/assets/vue/components/settings/elements/ListPostcodeComponent.vue +++ b/resources/assets/vue/components/settings/elements/ListPostcodeComponent.vue @@ -1,5 +1,5 @@ @@ -424,6 +444,26 @@ +
+
+
+
+
+
+
+ Permits +
+
+
+
+
+ +
+
+
+
+
+
diff --git a/routes/api.php b/routes/api.php index 873d648c..67946a9a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -34,6 +34,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function Route::post('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import')->name('debtor.import'); + Route::post('/import/upload-permits-reminder', 'Imports\ImportPermitsReminderController@import')->name('permits_reminder.upload'); + require __DIR__ . '/company.php'; require __DIR__ . '/document.php'; @@ -70,6 +72,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/help_menu.php'; + require __DIR__ . '/permits_reminder.php'; + }); require __DIR__ . '/announcement.php'; diff --git a/routes/permits_reminder.php b/routes/permits_reminder.php new file mode 100644 index 00000000..442d76f8 --- /dev/null +++ b/routes/permits_reminder.php @@ -0,0 +1,9 @@ + 'permits-reminder', 'as' => 'permits_reminder.', 'namespace' => 'PermitsReminder'], function () { + Route::get('/list', 'ListPermitsReminderController@list')->name('list'); + Route::delete('/{id}/delete', 'DeletePermitsReminderController@delete')->name('delete'); +}); + From d1426c7f053ad0643437716366c313c9f9d8ddc6 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 17 Jan 2024 00:43:17 +0800 Subject: [PATCH 21/89] all api and ui to create permits reminder --- .../CreatePermitsReminderController.php | 59 ++++++++++++ .../ListPermitsReminderController.php | 2 +- .../elements/PermitsReminderComponent.vue | 44 ++++++--- .../forms/AddPermitsReminderFormComponent.vue | 95 +++++++++++++++++++ routes/permits_reminder.php | 1 + 5 files changed, 185 insertions(+), 16 deletions(-) create mode 100644 app/Http/Controllers/PermitsReminder/CreatePermitsReminderController.php create mode 100644 resources/assets/vue/components/settings/forms/AddPermitsReminderFormComponent.vue diff --git a/app/Http/Controllers/PermitsReminder/CreatePermitsReminderController.php b/app/Http/Controllers/PermitsReminder/CreatePermitsReminderController.php new file mode 100644 index 00000000..388f8007 --- /dev/null +++ b/app/Http/Controllers/PermitsReminder/CreatePermitsReminderController.php @@ -0,0 +1,59 @@ + 'required', + 'expiry_date' => 'required|date|after_or_equal:today', + 'reminder_date' => 'required|date|after_or_equal:today', + ]; + + // Perform validation + $validator = Validator::make($request->all(), $rules); + + if ($validator->fails()) { + $validationErrors = $validator->errors()->all(); + $validationError = implode("
", $validationErrors); + + // Return validation error response + return response()->json([ + 'title' => 'Create Permits Reminder Failed', + 'message' => $validationError, + "payload" => [] + ], 422); // 422 Unprocessable Entity status code for validation errors + } + + // If validation passes, create the record + $record = PermitsReminder::create([ + 'expiry_date' => Carbon::parse($request->input('expiry_date'))->format('Y-m-d'), + 'reminder_date' => Carbon::parse($request->input('reminder_date'))->format('Y-m-d'), + 'model' => $request->input('model'), + ]); + + $response = [ + "title" => "Create Permits Reminder Successful", + "message" => "You have successfully created a Permits Reminder", + "payload" => [ + "data" => $record + ] + ]; + + return response()->json($response); + } +} diff --git a/app/Http/Controllers/PermitsReminder/ListPermitsReminderController.php b/app/Http/Controllers/PermitsReminder/ListPermitsReminderController.php index f5ad38fd..b2db4c58 100644 --- a/app/Http/Controllers/PermitsReminder/ListPermitsReminderController.php +++ b/app/Http/Controllers/PermitsReminder/ListPermitsReminderController.php @@ -18,7 +18,7 @@ class ListPermitsReminderController $page = request('page', 1); // Get the current page from the request // Paginate the PermitsReminder model - $query = PermitsReminder::query(); + $query = PermitsReminder::orderBy('id', 'desc'); $paginator = $query->paginate($perPage, ['*'], 'page', $page); // Convert paginated data to an array diff --git a/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue b/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue index 7c8bb13e..2034f218 100644 --- a/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue +++ b/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue @@ -1,10 +1,24 @@ @@ -78,6 +91,7 @@ export default { returnData: null, data: null, key: 1, + isUploadingCsv: false, } }, computed: { diff --git a/resources/assets/vue/components/settings/forms/AddPermitsReminderFormComponent.vue b/resources/assets/vue/components/settings/forms/AddPermitsReminderFormComponent.vue new file mode 100644 index 00000000..934522bc --- /dev/null +++ b/resources/assets/vue/components/settings/forms/AddPermitsReminderFormComponent.vue @@ -0,0 +1,95 @@ + + \ No newline at end of file diff --git a/routes/permits_reminder.php b/routes/permits_reminder.php index 442d76f8..fc4338c5 100644 --- a/routes/permits_reminder.php +++ b/routes/permits_reminder.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route; Route::group(['prefix' => 'permits-reminder', 'as' => 'permits_reminder.', 'namespace' => 'PermitsReminder'], function () { Route::get('/list', 'ListPermitsReminderController@list')->name('list'); + Route::post('/create', 'CreatePermitsReminderController@create')->name('create'); Route::delete('/{id}/delete', 'DeletePermitsReminderController@delete')->name('delete'); }); From b64b25ff0501c843ac7c94f887ae98506f2c81f5 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 17 Jan 2024 17:06:31 +0800 Subject: [PATCH 22/89] code update --- .../components/settings/elements/PermitsReminderComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue b/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue index 2034f218..b6846b55 100644 --- a/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue +++ b/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue @@ -9,7 +9,7 @@ @click="isUploadingCsv = !isUploadingCsv">{{ isUploadingCsv ? "Cancel" : "Upload Excel" }}
Add + data-type="addPermitsReminder" v-if="!isUploadingCsv">Add Permits
From a545e6bad6271db94e1c2efc53b6b3dce6224526 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 17 Jan 2024 17:19:37 +0800 Subject: [PATCH 23/89] 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 25/89] 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 26/89] 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 27/89] 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 28/89] 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 29/89] 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 30/89] 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 31/89] 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(); } From f83c89b5f380614499a9ef845f0a635871a80062 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 26 Jan 2024 04:03:06 +0800 Subject: [PATCH 32/89] Second high priority queue through database --- .../ControllersLogic/ListPackingListsJobLogic.php | 2 +- config/queue.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsJobLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsJobLogic.php index 8b8e672f..f3b3a8fc 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsJobLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsJobLogic.php @@ -64,7 +64,7 @@ class ListPackingListsJobLogic extends AbstractControllerLogic $userInfo ); - ListPackingListsJob::dispatch($listGenericJobObject); + ListPackingListsJob::dispatch($listGenericJobObject)->onQueue('high_priority'); $result = []; $result['job_id'] = $jobId; diff --git a/config/queue.php b/config/queue.php index 0f221cb6..f573796a 100644 --- a/config/queue.php +++ b/config/queue.php @@ -42,6 +42,14 @@ return [ 'after_commit' => false, ], + 'high_priority' => [ + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'shared_queue', + 'retry_after' => 3600, + 'after_commit' => false, + ], + 'beanstalkd' => [ 'driver' => 'beanstalkd', 'host' => 'localhost', From f389efa6afc2f03e0c5e58e0cc71f41f3070bd06 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 30 Jan 2024 00:07:31 +0800 Subject: [PATCH 33/89] add permits edit --- .../ImportPermitsReminderController.php | 2 +- .../CreatePermitsReminderController.php | 2 +- .../UpdatePermitsReminderController.php | 51 +++++++++++++++++++ app/Models/PermitsReminder.php | 6 +-- .../elements/PermitsReminderComponent.vue | 11 +++- .../elements/PermitsReminderItemComponent.vue | 8 +++ .../forms/AddPermitsReminderFormComponent.vue | 20 ++++++-- resources/views/pages/settings.blade.php | 2 +- routes/permits_reminder.php | 1 + 9 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 app/Http/Controllers/PermitsReminder/UpdatePermitsReminderController.php diff --git a/app/Http/Controllers/Imports/ImportPermitsReminderController.php b/app/Http/Controllers/Imports/ImportPermitsReminderController.php index bceaad37..2f82b628 100644 --- a/app/Http/Controllers/Imports/ImportPermitsReminderController.php +++ b/app/Http/Controllers/Imports/ImportPermitsReminderController.php @@ -40,7 +40,7 @@ class ImportPermitsReminderController $row['reminder_date'] = $this->changeExcelDate($row['reminder_date']); $validator = Validator::make($row, [ - 'model' => 'required', + 'model' => 'required|unique:permits_reminders,model', 'expiry_date' => 'required|date|after_or_equal:today', 'reminder_date' => 'required|date|after_or_equal:today', ]); diff --git a/app/Http/Controllers/PermitsReminder/CreatePermitsReminderController.php b/app/Http/Controllers/PermitsReminder/CreatePermitsReminderController.php index 388f8007..0e093b04 100644 --- a/app/Http/Controllers/PermitsReminder/CreatePermitsReminderController.php +++ b/app/Http/Controllers/PermitsReminder/CreatePermitsReminderController.php @@ -19,7 +19,7 @@ class CreatePermitsReminderController { // Define validation rules $rules = [ - 'model' => 'required', + 'model' => 'required|unique:permits_reminders,model', 'expiry_date' => 'required|date|after_or_equal:today', 'reminder_date' => 'required|date|after_or_equal:today', ]; diff --git a/app/Http/Controllers/PermitsReminder/UpdatePermitsReminderController.php b/app/Http/Controllers/PermitsReminder/UpdatePermitsReminderController.php new file mode 100644 index 00000000..14bcec7b --- /dev/null +++ b/app/Http/Controllers/PermitsReminder/UpdatePermitsReminderController.php @@ -0,0 +1,51 @@ + 'required|unique:permits_reminders,model,' . $request->route('id'), + 'expiry_date' => 'required|date|after_or_equal:today', + 'reminder_date' => 'required|date|after_or_equal:today', + ]; + + $validator = Validator::make($request->all(), $rules); + + if ($validator->fails()) { + $validationErrors = $validator->errors()->all(); + $validationError = implode("
", $validationErrors); + + return response()->json([ + 'title' => 'Update Permits Reminder Failed', + 'message' => $validationError, + "payload" => [] + ], 422); + } + + $record = PermitsReminder::findOrFail($request->route('id')); + + $record->model = $request->input('model'); + $record->expiry_date = Carbon::parse($request->input('expiry_date'))->format('Y-m-d'); + $record->reminder_date = Carbon::parse($request->input('reminder_date'))->format('Y-m-d'); + $record->save(); + + return response()->json([ + 'title' => 'Permits Reminder Updated', + 'message' => 'The permits reminder has been successfully updated.', + "payload" => $record + ]); + } +} diff --git a/app/Models/PermitsReminder.php b/app/Models/PermitsReminder.php index be494559..1f9762a9 100644 --- a/app/Models/PermitsReminder.php +++ b/app/Models/PermitsReminder.php @@ -18,16 +18,16 @@ class PermitsReminder extends Model public function getExpiryDateAttribute($value) { - return Carbon::parse($this->created_at)->format('d-m-Y'); + return $this->attributes['expiry_date'] === null ? NULL : Carbon::parse($this->attributes['expiry_date'])->format('d-m-Y'); } public function getReminderDateAttribute($value) { - return Carbon::parse($this->created_at)->format('d-m-Y'); + return $this->attributes['reminder_date'] === null ? NULL : Carbon::parse($this->attributes['reminder_date'])->format('d-m-Y'); } public function getCreatedAtAttribute($value) { - return Carbon::parse($value)->format('d-m-Y'); + return $this->attributes['created_at'] === null ? NULL : Carbon::parse($this->attributes['created_at'])->format('d-m-Y'); } } diff --git a/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue b/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue index b6846b55..c247096a 100644 --- a/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue +++ b/resources/assets/vue/components/settings/elements/PermitsReminderComponent.vue @@ -16,6 +16,7 @@
+
@@ -83,9 +84,14 @@ import { required } from "vuelidate/lib/validators"; export default { + props: { + section: { + type: String, + required: true + } + }, data() { return { - section: 'orderProfileSection', files: [], parameters: {}, returnData: null, @@ -112,7 +118,7 @@ export default { this.parameters = { files: this.files, }; - this.submit(this.route('api.permits_reminder.upload'), 'post', this.section, false, true); + this.submit(this.route('api.permits_reminder.upload'), 'post', this.section, true, true); }, errorHandler(error) { console.log(error); @@ -123,6 +129,7 @@ export default { }, refreshData() { this.returnData = null; + this.isUploadingCsv = false; this.key++; } }, diff --git a/resources/assets/vue/components/settings/elements/PermitsReminderItemComponent.vue b/resources/assets/vue/components/settings/elements/PermitsReminderItemComponent.vue index 692af867..07624dac 100644 --- a/resources/assets/vue/components/settings/elements/PermitsReminderItemComponent.vue +++ b/resources/assets/vue/components/settings/elements/PermitsReminderItemComponent.vue @@ -87,6 +87,14 @@ :section="section"> +
+ +
+ + +
diff --git a/resources/assets/vue/components/settings/forms/AddPermitsReminderFormComponent.vue b/resources/assets/vue/components/settings/forms/AddPermitsReminderFormComponent.vue index 934522bc..3f694063 100644 --- a/resources/assets/vue/components/settings/forms/AddPermitsReminderFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/AddPermitsReminderFormComponent.vue @@ -3,7 +3,7 @@
-
Add PERMITS REMINDER
+
{{ existingData ? 'Update' : 'Add' }} PERMITS REMINDER
@@ -53,6 +53,11 @@ import FormHandler from '../../../general/mixins/formHandler'; import { required } from "vuelidate/lib/validators"; export default { + props: { + existingData: { + type: Object, + } + }, data() { return { parameters: { @@ -62,6 +67,13 @@ export default { }, }; }, + mounted() { + if (this.existingData) { + this.parameters.expiry_date = this.existingData.expiry_date; + this.parameters.reminder_date = this.existingData.reminder_date; + this.parameters.model = this.existingData.model; + } + }, validations: { parameters: { expiry_date: { required }, @@ -71,10 +83,12 @@ export default { }, methods: { submitForm() { - this.submit(this.route('api.permits_reminder.create'), 'post', this.section, true, true) + var apiRoute = this.existingData ? this.route('api.permits_reminder.update', this.existingData.id) : this.route('api.permits_reminder.create'); + this.submit(apiRoute, 'post', this.section, true, true); }, errorHandler(error) { - this.formHandler(error.message); + // this.formHandler(error.message); + console.log(error); }, successHandler() { this.closeModal(); diff --git a/resources/views/pages/settings.blade.php b/resources/views/pages/settings.blade.php index 8f493630..039fa0c7 100644 --- a/resources/views/pages/settings.blade.php +++ b/resources/views/pages/settings.blade.php @@ -457,7 +457,7 @@
- +
diff --git a/routes/permits_reminder.php b/routes/permits_reminder.php index fc4338c5..ee254349 100644 --- a/routes/permits_reminder.php +++ b/routes/permits_reminder.php @@ -6,5 +6,6 @@ Route::group(['prefix' => 'permits-reminder', 'as' => 'permits_reminder.', 'name Route::get('/list', 'ListPermitsReminderController@list')->name('list'); Route::post('/create', 'CreatePermitsReminderController@create')->name('create'); Route::delete('/{id}/delete', 'DeletePermitsReminderController@delete')->name('delete'); + Route::post('/{id}/update', 'UpdatePermitsReminderController@update')->name('update'); }); From 295e6454b1d7eca83ebe8db42bc18d2701ed6ce6 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 30 Jan 2024 00:34:39 +0800 Subject: [PATCH 34/89] add cron job command to send permits reminder --- .../Notifications/PermitsReminderEmail.php | 36 +++++++++++ .../Commands/SendPermitsReminderEmails.php | 60 +++++++++++++++++++ .../reminder/permits_reminder.blade.php | 12 ++++ 3 files changed, 108 insertions(+) create mode 100644 app/Classes/Notifications/PermitsReminderEmail.php create mode 100644 app/Console/Commands/SendPermitsReminderEmails.php create mode 100644 resources/views/emails/reminder/permits_reminder.blade.php diff --git a/app/Classes/Notifications/PermitsReminderEmail.php b/app/Classes/Notifications/PermitsReminderEmail.php new file mode 100644 index 00000000..5524c949 --- /dev/null +++ b/app/Classes/Notifications/PermitsReminderEmail.php @@ -0,0 +1,36 @@ +user = $user; + $this->reminders = $reminders; + } + + public function toMail() + { + return (new MailMessage) + ->subject('Permits Renew Remidner Email') + ->view('emails.reminder.permits_reminder', ['user' => $this->user, 'reminders' => $this->reminders]); + } + + +} \ No newline at end of file diff --git a/app/Console/Commands/SendPermitsReminderEmails.php b/app/Console/Commands/SendPermitsReminderEmails.php new file mode 100644 index 00000000..28db7889 --- /dev/null +++ b/app/Console/Commands/SendPermitsReminderEmails.php @@ -0,0 +1,60 @@ +subDays(3)->startOfDay(); + $endRange = $now->copy()->addDays(6)->endOfDay(); + + $reminders = PermitsReminder::whereDate('reminder_date', '>=', $startRange) + ->whereDate('reminder_date', '<=', $endRange) + ->pluck('model'); + + $this->info(json_encode($reminders)); + + $users = User::whereIn('email', ['edmond.wuiming2021@gmail.com'])->get(); + + foreach ($users as $user) { + $this->info('Reminder email sent to ' . $user->email); + $user->notify(new PermitsReminderEmail($user, $reminders)); + } + } +} diff --git a/resources/views/emails/reminder/permits_reminder.blade.php b/resources/views/emails/reminder/permits_reminder.blade.php new file mode 100644 index 00000000..7221afa1 --- /dev/null +++ b/resources/views/emails/reminder/permits_reminder.blade.php @@ -0,0 +1,12 @@ +@extends('emails.layout.base') + +@section('content') +

Hello, {{ $user->first_name.' '.$user->last_name }}

+

The permits listed below either expiring within the period of the next 3 days or have already expired 3 days ago.

+ +
    + @foreach($reminders as $reminder) +
  • {{ $reminder }}
  • + @endforeach +
+@endsection \ No newline at end of file From 3d6543e467e75de511cbf55af517b4c4c2228f8c Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 30 Jan 2024 00:42:21 +0800 Subject: [PATCH 35/89] add sample file --- .../permits_reminder_template.xlsx | Bin 0 -> 10122 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/excel-templates/permits_reminder_template.xlsx diff --git a/public/excel-templates/permits_reminder_template.xlsx b/public/excel-templates/permits_reminder_template.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..b72e82f1f67d5efa578f99bb901e869cc1f777fd GIT binary patch literal 10122 zcmeHt^AASnn)r!<0uNZmSMS#{7-KgmD;Vw~rAu|HiOqZMxcyzdnFROnp$p`_v#)XGe6He1NM&E+3 zY_@kVr`Zf4+D?w>FdaxL%1iv_O$0C*pp|VK%wrYW0k_GhQx3~Q(Uz0iBhA9N&?A5; z#@_Y#YTv-FH^&A3z1$A>jO!VEgcb>N+VuAElq|e|vFkj6b8%8A*1LGWXtmD{JD551 z*o6~`R^^j0plI|S50r(G2VcD<9TLTfM_~maXUx`>?bAU%*Y#It-YR4S+xFYZQu50B z>^4cFfmD9VGq9078u~0O)sS1^w$bjsQ?BOnsDt~;BW#M;&wNLo&zHpF1z;uSh}z^o zJP#+QsiXFD&-)l{Zx7d6gLy5p2_*4qi%mz)Q!=E8Ds4iOMW(j6LXllEyrs%LOMULV zby6alIuI{U3mWYKnYw=ydKl_if^zHO0S=)27YD`F|7;2ib$K9Ee_@$zc}K>Bg;-1uc;%4|8{q$RG=X z;WCAKrEXmB@gr0>XG?-{edZITJU2O-xiIszY@hUJUUF7EHy(L4%7-(u zSb6i0F7sA6HsKU{r4i~fBmiU>SL-K#c#R9l!O92(vigzL{_8<7(9{NXumA0%SXEKJ zivz0#^?NXfOR_UQ_N?O*>OGBJOyvG*CI~&%Q}44SQszcIttt5@aG)T!!{J`%OCF3B zINbAgmi#arcz0auLqP=4@aZrdveAACxt}xwF3#T0ZqYs}MiLmeK{&dPH4Tq{tXOAxo^2!|7wC3uW%Kv8>fuzJn+CO~bk#IL%pjxvb}xc<-}4!J=5ME|MoN5h@Axe71Z3OjHxkf&|JHFVa7lh} z-JKh~^_G;ST8{HM3g-&*bf9t(-kXO8v=NTV_XU2kC9Yw0^DE)wn@XEjHV1^SmuLXW zyxloqC$W%Wd3{cgOsi7L%86Vfj9Q?iwGBUub$>$pMBrvkWMo0Nwp-^H;EUz`yi;JKhbK`G( z0V3#zAvZCUj*jYd4p}Aojkvz_WZN|N+_bTuW!g9RkwD@kSe+CBWy@)C#Ghj(?LP1b z`HmlTn&TBuy3@T~Yr$n(1cx7Oc{0(qZWo7Z={*?5mBn_+aP8&>+BM4@6VB}Lh|Gs@ zaw*=IVB=)QO0|W*yKqh;oe|yd{bHZ>aTT}Zv6hYWeO9ey1w#%ZZr0Krhz2bfgv1K( zU|{0bLEt>18%jc>rclbZMbn&5tHu(&T@y|6nd)T7b8lw*!B8aL;~XB(rMU6j>Rfb$ zwxxSxgi>p?k|J`04Y zgDw0Ui1_+FfsJh-^I4-t_5QRy^39aZH%+`!1$%`Iuk*{#;0orqHWCG`ClG>K9EvX82ZLb-m z-dh;Hx?KS6(bBR-ma8x9?vz@}8}&S0P5flmv%1`*Cs%_s1n#JevR%?@466FbCR1gVijw9%hkV9tUUDI8OX2w~8(p_F&q+ z^7&VXv|^v$vbD9O$0AtU9sc@4&Cv-y-|%-<4Li7^tT-V+qwL!@y*bAtI^z%8w5_mx zvFfXa-!(i$@uaL59%C9y5l_P#!02X3amB9q8HF)w+hz7mg>3p}7y(D)j32$Avyf~1 z*wMGL0$DF0iO93-JR2<1BSl(aMuJX`-l%oW^Kc<84w`7nRBNShy>J9}U*;l?ERBGov@@Wt7rQ{-K zM|oX=rV{$iQtBEo7|NOB!WH>FPH4GBzS=rjs=&4N@ita8-9?eKmdv%*5sQA0_>5W+ zYd7&8-4H_Py5_rOd_ss>f-jyKYG-hm zWi;XC6EQHJ`ffT*%K*HPyEw)Y=N+W_RX5rutF^7)9*SZFFzn`11Z9{(yow0xVeZaN zEOqXP8fIlmE78Vr<8|8Snf&Y&O}M4t2~!5Q^xiM3e$Z}7}ZRl zJ};~xL{#SaRIFbZR`7h`;T5ZcuI?+RFJMS&&fPY7v##0p;mekc5zF9Icyug{8ZAD1 z7OW-KgQ1{a9~3%Fotxrt!NN1X@_xZ~myotRDRcy}Lm4`?>4&2OB+S^Tx2C z7!A><7mlFa>Fm-qIb9Rmkj zM9E&YZrH_8~-HZL)gN#)j+|k;1 z`DU|0yIF0>cWGu4Y5PN-mjr(4(_;%wCo6+oHcj>KV+K6nU|tEtnrJNMS4x8Ma1fho zSv!h_45y}ZR(<|47gS55!lJ_i05#D1jp&bD@S}tSo12u ziRD~G>oXFZVisbcx<;X;htB@yET?$6k@1xC=jyqK&&IeiIgfdnVM&2Pqk{gu;dxn_ zCYV#QU*oyuRprw0bEEfjvqe6)z9eU|PpiX!l^YnH);6BEzL3}5K2u@^5PBiDD>vu5 zg#S)p+;@YWldO8HAYyWUHE)4qTKk&@+Ly3(i)Y43gYg#u9g7_tPHYIxL=|7hZpe*Z z*nhZgl5)09x3EWj32s_&!ZmaZ4yjT9@`*YYhb^p5(TepAOY!YT#Rf|0aF_R^_msH% zujF1ovPvoN@-vy*^wj&FGE7WJv)%YTnPWCqduFiwEus4NirC8FsJJ%`@{=ftet+%Q&J*o?b`m~s^*6OYg!uc&d@4p-MCkbj1 zpUZ20ejzI)fIs1xch}9YR5{C?x{jH3SR~+y*kB`%NhO%d-@HCVOIZGK+ zI@6RtVdnka%=F~oy0+i)$R{yyrp{gppL-vjIwzvB8z<3br@*w1xc!n51X?2ecD%$M1xZk1 z%`(iS>*Ju)3_%yg^ZV-${zoSt4^~iq1l}{t^A&Hsj~FA6h#(E;{?eiwMn< z3NaI!1FbBpcoL_j%k)Wf))R6EZr5BHg5i3@1YajE+rFP4btWAP{^qNMgt|D_EVl2? zMI;c$@2EnsZgLbqk}!P=S-4a7&LhCYZ?4f!zH1bq#pBDM%RqzGanCSE(Vv2aMPF|npL1(tE!>AY}JE#JmoS|+U^3NzoZg6+E28>h5E_?myDi{7QFoPsw` zd@?i-hd!&B9`Wb_!*a&CeaKmesoXES51$_$GCq_H#d7beRr8uhfE=Gp3}4E1*5X=c zb%1$j1&?K=0yiz|ox0XGzKg$oG&-rg6Cyi=0R4^8$xl_?wKPbTfl)Hh;q(^sP~_+P z{5e!I$tWnDE3(Rs4zXzV$tto`XmE`^< zm_GSA{)`@b+DactdGK0kj>)9Jd9u!@dD=WW`x{DxjS$U+>U?Rlo<#dq;t$qlbqyI8 zAprr5A*eWf7|8h(a=HU~+KhhG=PXBii9<7_!8U`M%=!IvtJf`?o0n-mqoWOu*ZN{D zG(!l67Na2D{9E#ua0JoZJJ)qRS(xlMX_1WR*rrSe*Ql&_gOI~k7ZjU*B8C~bYjx|4 zGz$4dn@LM*Uqf2?wW#e(1DIdgcaD@lw@$d>1|Yx`bJulG%+Bo} zV7x|{0<4RWH6o?913NoNZ}?tWFIp6o1x}~y`hXEcNY2~C3H1FPJO`I!pl`@xnTN5r z?$uH1%}Dxe#SsafTJ(tK*tw=hRjaNIN+MU|W`K*%u!>ohvVI07>A;?ohs=Fwo-3a)J6nM9i`y~lTHVm~q! z3$Np|U_vDdk0)uu&l(=q*1nH2V3McIKQK+3q8wy!b0K{4xx9X} z41L(|Rr0xCN9Du1P%#~^DkH!Dz6L#s+^*gRV_acKrg6D4=yp!>c?OP2(Ci^^lZK_K$TwuNLs|^=69ZX~4gf7n0N&X67q<7_EZ5e4Lo^`~!bz-3|M>mWZwn&YY!Fttq zdW#Z_zT_A^b4jdt?X!c8Np&)b&D+dx&I)|6xMyJUx9-4b-4?FYQ+orXsnY3VB zQeCt zRQBz_M%$SZy$m)LjPE|G;@{J$520aOwWk-M=MsLWf|z$1WGh6YlK(y+ffGhAi+l>5 zO*lvA5^%ca8|XGYYo3qslmYXt36DM~Zgq^a@A1Ncda8PX{$*~|folRHN=$IeH2E{FPX~ zi@~kJZz)#U(*iL`#LB_)5!7&nGA?l?Rtb5U33+q!5_4P~GJFtZ8gyg46>7oZ-4Cbl zoa!DGn5H>&JMgIk9oavJYO&x5bfa_gB>Lqp+K+-jwcl)6M72jhiCtod#GpAy=f|*R zV(WS%L~oLQclt=TDuxjm0uHwN(mzW{g#-Q&oxNGKo-iw_HcT~F+k=SJp<|^>XufXq z6vNLJiC8I*KN2_-f$c?>1=DsU@QQ!Q@^~7FMV2?%j-qF|f-eK?jr$_3<{A2WTO@M* zipAO@8p^y}yoBcZQbC9MSg9LZKA4e0nmb%YMMZ&YbU8^v9(<I>V~MRUp-1AuOUa^Rio4L-^oGrLvIl8e?I)7v=rK!m~*5g$4hCFll@vU zMoTA~Cw{jyJSHIII=(!${+``smx%C{;6@ z9@p2dqE*gXT2_gaC2gqt#QGcdz=px$e7$JjNlRn|x>vF17YiEFO{FUF#$9*zj~g*~ z15{zh=qoW!uRD%Ok%ZmC{cl++C+|$m>XKKtoWl1|z0sa+-|!-VSWAh*?a?e!H6smF zJGkXGu^5QHMr-amYP9+r2*oiWtJB<{K`eK*k?M$g2zM1!D&{UN;)Yfy-_iA35@@Wa z#5tuD%S)}AiE%j=m~9mwD`jl4I$pXSy42#jtWRL>Yks8ghL^^s<<6$Ukd=_VOGaGGu72iuEhY4DIaxr5JR|{&S>658FaGumTPdZZKdEIoGR^ANd<$ z(K0!hE5kW|IgNjY!x7qj&6+ z!UxRf)%WhllK5R%R>(|7Iqzk5=DhC=rUaZm&eGr;VHc>ff$P2`>4tlx2Nq{pC&ga2 zec4ETsklnENO#%T+jmpRTEB6NRvs$?Mz*7=KdbQ=|u?Ihslw69s2s6mG zpXDN;Vp;DBze&Sj8Gh^EX>g_s3;_Ed@OTK%ec5ue;>Cbn9Kf!9D{6jr+a^Sbc3jeK zR++o0@!`E1d*4Ge;EBdDE;3TN+Z`~qi9EcQbbwUJ-m$-eN1o8Q#3D@fBvkfTa2(4HH&u$58 z|2amsGLMZbLD_2njgi>Dvey{oVEQk8|4Uu~z%yD8EHJNZxOyu-vt--NRW-2oA=LUVovvNNBD$#VkpS9EB7%ovAJvR(n0r zDxOxMfTB71NYxSEKYsRHql0w73VpQERuqEsZc}DJc`@4@WFyYW>xmhi*v1o!>QWOw z)R@C=*Lj7+0+2T3@5N!o9pajYxd+l_;;J5D&wB0@A|b!efJGS~QGoUHX(XuT_95Sj zkyVSon5pMWbQuGjTPa~Tz{8=lYi%XU z;95D3US`x|JD=i07jkQSL2FVHPzNlOIXawKcE5d#(g7BBEEi!YJMJ|8ET)YoRYAdi zXPy@Pl!T2jbg2pQWW>e0Ge}6_PATP@>bPHs0Xwz(Y{OYh2(EJR_C(3#Ppu9HmJO4{0Ds+7@hdx$8crboTrd8Agy!FIe%BlS zL_$LOoBH^>@$b^lpT-TSKaKw;1pSWiyKeF)!e_KU5dKd^`Q7yQHrt=3133Tp&;QnR z`yJ)?mG++~=!8E}eqVS04)E7H&50J1sbN~PV literal 0 HcmV?d00001 From 5b4a3507a3f9ca308d344057d1f3e4aeb8c0354e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 30 Jan 2024 00:48:23 +0800 Subject: [PATCH 36/89] add cron job to send permits reminder at daily 9.30 am --- app/Console/Kernel.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0235a1d2..1e324303 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -67,6 +67,11 @@ class Kernel extends ConsoleKernel ->dailyAt('0:01') ->withoutOverlapping() ->appendOutputTo(storage_path().'/logs/check_storage_invoices.log'); + + $schedule->command('permitsReminder:send') + ->dailyAt('09:30') + ->withoutOverlapping() + ->appendOutputTo(storage_path().'/logs/permits-reminder-send.log'); } /** From 2c1b85725555d1cc4193e50da27ed8b8a3788e95 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 30 Jan 2024 12:37:34 +0800 Subject: [PATCH 37/89] update permits reminder view --- resources/views/pages/settings.blade.php | 80 ++++++++++++------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/resources/views/pages/settings.blade.php b/resources/views/pages/settings.blade.php index 039fa0c7..1abac87d 100644 --- a/resources/views/pages/settings.blade.php +++ b/resources/views/pages/settings.blade.php @@ -46,6 +46,26 @@ +
+
+
+
+
+
+
+
+ +
+
+
Permits
+
+
+
+
+
+
+
+
@@ -245,6 +245,26 @@ +
+
+
+
+
+
+
+ Permits +
+
+
+
+
+ +
+
+
+
+
+
From de61d9a9fd6e411913239d65cb624c8d92e026eb Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 30 Jan 2024 12:41:51 +0800 Subject: [PATCH 38/89] add anitha email for premits reminder --- app/Console/Commands/SendPermitsReminderEmails.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/SendPermitsReminderEmails.php b/app/Console/Commands/SendPermitsReminderEmails.php index 28db7889..58989c55 100644 --- a/app/Console/Commands/SendPermitsReminderEmails.php +++ b/app/Console/Commands/SendPermitsReminderEmails.php @@ -50,7 +50,13 @@ class SendPermitsReminderEmails extends Command $this->info(json_encode($reminders)); - $users = User::whereIn('email', ['edmond.wuiming2021@gmail.com'])->get(); + $users = User::whereIn( + 'email', + [ + 'edmond.wuiming2021@gmail.com', + 'anithagurl96@gmail.com' + ] + )->get(); foreach ($users as $user) { $this->info('Reminder email sent to ' . $user->email); From ef6538fecaa0d8e602ab37e998a4efd9d443f9a3 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Mon, 5 Feb 2024 12:47:51 +0800 Subject: [PATCH 39/89] fix container reschedule component --- .../containers/forms/RescheduleDateFormComponent.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue index 211377a7..0bff5b3b 100644 --- a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue +++ b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue @@ -3,7 +3,7 @@
-

Plese set the approximate dates of below.

+

Please set the approximate dates of below.

@@ -12,13 +12,13 @@
- +
- +
@@ -43,8 +43,8 @@ data() { return { parameters: { - etd: this.etd, - eta: this.eta, + etd: this.etd, + eta: this.eta, } }; }, @@ -57,4 +57,4 @@ mixins: [modalFormHandler] } - \ No newline at end of file + From e63b9597146f547231302bb271ecea08fd20c93a Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Mon, 5 Feb 2024 12:52:07 +0800 Subject: [PATCH 40/89] fix container reschedule component --- .../containers/forms/RescheduleDateFormComponent.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue index 0bff5b3b..6b655685 100644 --- a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue +++ b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue @@ -12,13 +12,13 @@
- +
- +
@@ -43,8 +43,8 @@ data() { return { parameters: { - etd: this.etd, - eta: this.eta, + etd: this.data.etd, + eta: this.data.eta, } }; }, From 4b967981dd59f9718bae9062cdca7a9264d9b62d Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Mon, 5 Feb 2024 12:56:30 +0800 Subject: [PATCH 41/89] fix container reschedule component --- .../containers/forms/RescheduleDateFormComponent.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue index 6b655685..20b92740 100644 --- a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue +++ b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue @@ -12,13 +12,13 @@
- +
- +
From 5517f16684b2fe60eb031ba3cd563d5e24e76323 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Mon, 5 Feb 2024 13:24:25 +0800 Subject: [PATCH 42/89] fix container reschedule component --- .../containers/forms/RescheduleDateFormComponent.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue index 20b92740..d75255c6 100644 --- a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue +++ b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue @@ -9,7 +9,7 @@
-
+
@@ -43,8 +43,8 @@ data() { return { parameters: { - etd: this.data.etd, - eta: this.data.eta, + etd: this.data.transport.current_schedule.etd, + eta: this.data.transport.current_schedule.eta, } }; }, From 4c0984c9b83c6d424e803d177228be88ecb2cb2c Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Mon, 5 Feb 2024 15:08:51 +0800 Subject: [PATCH 43/89] fix container reschedule component --- .../components/containers/forms/RescheduleDateFormComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue index d75255c6..6564a0fa 100644 --- a/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue +++ b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue @@ -9,7 +9,7 @@
-
+
From 9d87987488d262d7c0914b1a2e28576084d9eb77 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 6 Feb 2024 10:55:19 +0800 Subject: [PATCH 44/89] code update - permits reminder - send email only at production --- .../Commands/SendPermitsReminderEmails.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/SendPermitsReminderEmails.php b/app/Console/Commands/SendPermitsReminderEmails.php index 58989c55..c81df2f7 100644 --- a/app/Console/Commands/SendPermitsReminderEmails.php +++ b/app/Console/Commands/SendPermitsReminderEmails.php @@ -5,6 +5,7 @@ namespace App\Console\Commands; use App\Classes\Notifications\PermitsReminderEmail; use App\Models\PermitsReminder; use App\Models\User; +use Carbon\Carbon; use Illuminate\Console\Command; class SendPermitsReminderEmails extends Command @@ -48,19 +49,26 @@ class SendPermitsReminderEmails extends Command ->whereDate('reminder_date', '<=', $endRange) ->pluck('model'); - $this->info(json_encode($reminders)); + $this->info($this->getTimeStamp() . json_encode($reminders)); $users = User::whereIn( 'email', [ - 'edmond.wuiming2021@gmail.com', + // 'edmond.wuiming2021@gmail.com', 'anithagurl96@gmail.com' ] )->get(); foreach ($users as $user) { - $this->info('Reminder email sent to ' . $user->email); - $user->notify(new PermitsReminderEmail($user, $reminders)); + $this->info($this->getTimeStamp() . 'Reminder email sent to ' . $user->email); + if (app()->environment('production')) { + $user->notify(new PermitsReminderEmail($user, $reminders)); + } } } + + public function getTimeStamp() + { + return '[' . Carbon::now()->format('Y-m-d H:i:s') . '] - '; + } } From 0b415e2e33c044cbfb46b96ad64b59181ee72e1e Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 8 Feb 2024 18:41:57 +0800 Subject: [PATCH 45/89] Vue Polling - Solve a problem where query of packing list with contaienrs and packages data is taking too long to complete + pagination problem --- .../Filters/WithContainersPackages.php | 5 +- .../ListPackingListsJobProcessor.php | 18 +++++-- .../ListPackingListDetailsJobResource.php | 47 +++++++++++++++++++ .../Resources/ListPackingListJobResource.php | 2 +- 4 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 app/Http/Resources/ListPackingListDetailsJobResource.php diff --git a/app/Classes/General/Eloquent/Filters/WithContainersPackages.php b/app/Classes/General/Eloquent/Filters/WithContainersPackages.php index 5fabff27..b4f30b31 100644 --- a/app/Classes/General/Eloquent/Filters/WithContainersPackages.php +++ b/app/Classes/General/Eloquent/Filters/WithContainersPackages.php @@ -4,6 +4,7 @@ namespace App\Classes\General\Eloquent\Filters; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\Log; class WithContainersPackages implements Filter { @@ -15,6 +16,8 @@ class WithContainersPackages implements Filter */ public static function apply(Builder $builder, $value) { - return $builder->with(['containers', 'packages']); + // Log::info('WithContainersPackages: '.$value); + // return $builder->with(['containers', 'packages']); + return null; } } diff --git a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php index 2f3a5eed..535e5d29 100644 --- a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php @@ -8,6 +8,7 @@ use App\Classes\Modules\Jobs\Processors\UpdateJobResultProcessor; use App\Classes\General\Helper; use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject; use App\Http\Resources\ListPackingListJobResource; +use App\Http\Resources\ListPackingListDetailsJobResource; class ListPackingListsJobProcessor { @@ -36,15 +37,22 @@ class ListPackingListsJobProcessor * @throws \App\Classes\Exceptions\JobResourceNotFoundException */ 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(array_merge($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']]); + // $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(); } - $resultCurrent = Helper::collectionResponse(ListPackingListJobResource::collection($query)); - $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent); + + $filtersArray = json_decode($listGenericJobObject->getPayload()['filters'], true); + if(isset($filtersArray['does_not_have_transaction_type'])){ //For Pending Invoice query + $resultCurrent = Helper::collectionResponse(ListPackingListDetailsJobResource::collection($query)); + $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent); + } + else{ + $resultCurrent = Helper::collectionResponse(ListPackingListJobResource::collection($query)); + $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent); + } } } diff --git a/app/Http/Resources/ListPackingListDetailsJobResource.php b/app/Http/Resources/ListPackingListDetailsJobResource.php new file mode 100644 index 00000000..48bed481 --- /dev/null +++ b/app/Http/Resources/ListPackingListDetailsJobResource.php @@ -0,0 +1,47 @@ +userInfo ? $this->userInfo->type : Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]); + $packages = !$this->packingLists()->exists() || $exceptionUsers ? $this->packages : $this->packingLists->first()->packages; + + return [ + 'id' => $this->id, + 'claimant_id' => $this->claimant_id, + 'reference' => $this->reference, + 'status' => $this->status, + '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) + // ]), + 'container' => new ContainerResource($this->containers->first()), + '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/ListPackingListJobResource.php b/app/Http/Resources/ListPackingListJobResource.php index 6b13be59..db094db1 100644 --- a/app/Http/Resources/ListPackingListJobResource.php +++ b/app/Http/Resources/ListPackingListJobResource.php @@ -31,7 +31,7 @@ class ListPackingListJobResource extends JsonResource 'status' => $this->status, '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)), + // '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) From 1bcad555a09e25c62b8495bc091be255f61135a7 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 13 Feb 2024 22:06:38 +0800 Subject: [PATCH 46/89] Second high priority queue through database --- config/queue.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/queue.php b/config/queue.php index f573796a..d86a8f5b 100644 --- a/config/queue.php +++ b/config/queue.php @@ -34,18 +34,18 @@ return [ 'driver' => 'sync', ], - 'database' => [ + 'high_priority' => [ 'driver' => 'database', 'table' => 'jobs', - 'queue' => 'default', + 'queue' => 'high_priority', 'retry_after' => 3600, 'after_commit' => false, ], - 'high_priority' => [ + 'database' => [ 'driver' => 'database', 'table' => 'jobs', - 'queue' => 'shared_queue', + 'queue' => 'default', 'retry_after' => 3600, 'after_commit' => false, ], From 1b6fe7445ea303ae7828cbd5c5d471b81c155cc6 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 15 Feb 2024 20:45:32 +0800 Subject: [PATCH 47/89] User interface to allow admin to waive warehouse storage invoice transaction --- .../DeleteTransactionLogic.php | 2 +- .../WaiveTransactionLogic.php | 62 +++++++++++++++++++ .../WaiveTransactionObject.php | 49 +++++++++++++++ .../Services/UpdatesTransactionIsWaived.php | 22 +++++++ .../Standards/Rules/CanWaiveTransaction.php | 58 +++++++++++++++++ .../Validators/WaiveTransactionValidation.php | 42 +++++++++++++ .../WaiveTransactionController.php | 21 +++++++ .../TransactionWithStorageResource.php | 1 + ...stomerPaymentsBillingVariant2Component.vue | 18 +++++- .../forms/WaiveInvoiceFormComponent.vue | 30 +++++++++ routes/transaction.php | 1 + 11 files changed, 303 insertions(+), 3 deletions(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php create mode 100644 app/Classes/Modules/Transactions/DataTransferObjects/WaiveTransactionObject.php create mode 100644 app/Classes/Modules/Transactions/Services/UpdatesTransactionIsWaived.php create mode 100644 app/Classes/Modules/Transactions/Standards/Rules/CanWaiveTransaction.php create mode 100644 app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php create mode 100644 app/Http/Controllers/Transactions/WaiveTransactionController.php create mode 100644 resources/assets/vue/components/paymentsBilling/forms/WaiveInvoiceFormComponent.vue diff --git a/app/Classes/Modules/Transactions/ControllersLogic/DeleteTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/DeleteTransactionLogic.php index 56d24523..7fff74f5 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/DeleteTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/DeleteTransactionLogic.php @@ -30,7 +30,7 @@ class DeleteTransactionLogic extends AbstractControllerLogic /** - * SuspendTransactionLogic constructor. + * DeleteTransactionLogic constructor. * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus */ diff --git a/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php new file mode 100644 index 00000000..03d0b163 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php @@ -0,0 +1,62 @@ + 'Waive Transaction', + 'message' => 'You have successfully waived the transaction' + ]; + } + + /** @var FetchesTransaction */ + private $fetchesTransaction; + + /** @var UpdatesTransactionIsWaived */ + private $updatesTransactionIsWaived; + + /** @var CanWaiveTransaction */ + private $canWaiveTransaction; + + + /** + * WaiveTransactionLogic constructor. + * @param FetchesTransaction $fetchesTransaction + * @param UpdatesTransactionIsWaived $updatesTransactionIsWaived + * @param CanWaiveTransaction $canWaiveTransaction + */ + public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionIsWaived $updatesTransactionIsWaived, CanWaiveTransaction $canWaiveTransaction) + { + $this->fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionIsWaived = $updatesTransactionIsWaived; + $this->canWaiveTransaction = $canWaiveTransaction; + } + + + public function logic(Request $request) : JsonResponse + { + $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); + + $object = new WaiveTransactionObject($transaction->id, $transaction->bill_no, $transaction->type); + $this->canWaiveTransaction->passes($object); + + $this->updatesTransactionIsWaived->execute($transaction); + + return $this->response([]); + } +} diff --git a/app/Classes/Modules/Transactions/DataTransferObjects/WaiveTransactionObject.php b/app/Classes/Modules/Transactions/DataTransferObjects/WaiveTransactionObject.php new file mode 100644 index 00000000..3ae7a3f1 --- /dev/null +++ b/app/Classes/Modules/Transactions/DataTransferObjects/WaiveTransactionObject.php @@ -0,0 +1,49 @@ +id = $id; + $this->billNo = $billNo; + $this->type = $type; + } + + /** + * @return int + */ + public function getId(): string + { + return $this->id; + } + + /** + * @return string + */ + public function getBillNo(): string + { + return $this->billNo; + } + + /** + * @return int + */ + public function getType(): string + { + return $this->type; + } +} diff --git a/app/Classes/Modules/Transactions/Services/UpdatesTransactionIsWaived.php b/app/Classes/Modules/Transactions/Services/UpdatesTransactionIsWaived.php new file mode 100644 index 00000000..9f9a6ae3 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/UpdatesTransactionIsWaived.php @@ -0,0 +1,22 @@ +is_waived = 1; + + return $this->handler($model); + } +} diff --git a/app/Classes/Modules/Transactions/Standards/Rules/CanWaiveTransaction.php b/app/Classes/Modules/Transactions/Standards/Rules/CanWaiveTransaction.php new file mode 100644 index 00000000..5a596acb --- /dev/null +++ b/app/Classes/Modules/Transactions/Standards/Rules/CanWaiveTransaction.php @@ -0,0 +1,58 @@ +waiveTransactionValidation = $waiveTransactionValidation; + } + + /** + * @return bool + */ + protected function authorized($object): bool + { + $user = Auth()->user(); + if($user){ + $roleToCheck = Auth()->user()->type; + if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) { + return true; + } + } + + return false; + } + + /** + * @param WaiveTransactionObject $object + * @return bool + * @throws \App\Classes\Exceptions\RequestValidationException + */ + protected function validators($object): bool + { + return $this->waiveTransactionValidation->validate($object); + } + + /** + * @param $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} diff --git a/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php b/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php new file mode 100644 index 00000000..1c4a45b3 --- /dev/null +++ b/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php @@ -0,0 +1,42 @@ + $object->getId(), + 'billNo' => $object->getBillNo(), + 'type' => $object->getType(), + ]; + } + + /** + * @return array + */ + protected function rules(): array { + return [ + 'id' => 'required', + 'type' => ['required', 'numeric', 'in:16'], //Only storage invoice (type 16) can be waived + // 'billNo' => 'required', + ]; + } + + /** + * @return array + */ + protected function messages(): array { + return []; + } + +} diff --git a/app/Http/Controllers/Transactions/WaiveTransactionController.php b/app/Http/Controllers/Transactions/WaiveTransactionController.php new file mode 100644 index 00000000..cb36a973 --- /dev/null +++ b/app/Http/Controllers/Transactions/WaiveTransactionController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Resources/TransactionWithStorageResource.php b/app/Http/Resources/TransactionWithStorageResource.php index d9b0822f..d072913a 100644 --- a/app/Http/Resources/TransactionWithStorageResource.php +++ b/app/Http/Resources/TransactionWithStorageResource.php @@ -120,6 +120,7 @@ class TransactionWithStorageResource extends JsonResource ), 'remarks' => RemarkResource::collection($this->remarks), 'storages' => $this->storages ? $this->storages : null, //from middleware + 'is_waived' => (int) $this->is_waived, 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:s:i'), 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y'), 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y') diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue index a8ce2941..4d294cf1 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue @@ -68,11 +68,25 @@
+
+ + Waive Transaction + + + Transaction Waived + + + N/A + + + + +
- + - +
diff --git a/resources/assets/vue/components/paymentsBilling/forms/WaiveInvoiceFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/WaiveInvoiceFormComponent.vue new file mode 100644 index 00000000..9895bbd1 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/WaiveInvoiceFormComponent.vue @@ -0,0 +1,30 @@ + + diff --git a/routes/transaction.php b/routes/transaction.php index 7c2e600f..caa5b6fb 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -10,6 +10,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::delete('/delete-payment/{id}', 'DeletePaymentTransactionController@delete')->name('payment.delete'); Route::put('{id}/status/update/{status}', 'UpdateTransactionStatusController@update')->where('status', 'approve|expire|reject')->name('update'); route::post('/{invoice_id}/regenerate', 'RegenerateSingleShippingInvoiceTransactionController@regenerate')->name('invoice.regenerate'); + Route::post('/waive/{id}', 'WaiveTransactionController@waive')->name('waive'); Route::get('wallet/list', 'ListWalletTransactionsController@list')->name('wallet.list'); From 8a7a4ce38a62b600d96998da033a7f57373e601a Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 15 Feb 2024 21:01:50 +0800 Subject: [PATCH 48/89] User interface to allow admin to waive warehouse storage invoice transaction --- .../Transactions/ControllersLogic/WaiveTransactionLogic.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php index 03d0b163..83f53e39 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php @@ -10,6 +10,8 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived; use App\Classes\Modules\Transactions\Standards\Rules\CanWaiveTransaction; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Log; class WaiveTransactionLogic extends AbstractControllerLogic { @@ -56,6 +58,7 @@ class WaiveTransactionLogic extends AbstractControllerLogic $this->canWaiveTransaction->passes($object); $this->updatesTransactionIsWaived->execute($transaction); + Log::info(Auth::user()->email." waive storage invoice charges with bill_no: ".$transaction->bill_no); return $this->response([]); } From c427ae42a0026d4c4f8c5644cfa53a00f954d143 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 15 Feb 2024 21:18:02 +0800 Subject: [PATCH 49/89] User interface to allow admin to waive warehouse storage invoice transaction --- .../ControllersLogic/WaiveTransactionLogic.php | 2 +- .../WaiveTransactionObject.php | 18 +++++++++++++++--- .../Validators/WaiveTransactionValidation.php | 2 ++ ...ustomerPaymentsBillingVariant2Component.vue | 4 ++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php index 83f53e39..61e48ac0 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php @@ -54,7 +54,7 @@ class WaiveTransactionLogic extends AbstractControllerLogic { $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); - $object = new WaiveTransactionObject($transaction->id, $transaction->bill_no, $transaction->type); + $object = new WaiveTransactionObject($transaction->id, $transaction->bill_no, $transaction->type, $transaction->status); $this->canWaiveTransaction->passes($object); $this->updatesTransactionIsWaived->execute($transaction); diff --git a/app/Classes/Modules/Transactions/DataTransferObjects/WaiveTransactionObject.php b/app/Classes/Modules/Transactions/DataTransferObjects/WaiveTransactionObject.php index 3ae7a3f1..452a75d6 100644 --- a/app/Classes/Modules/Transactions/DataTransferObjects/WaiveTransactionObject.php +++ b/app/Classes/Modules/Transactions/DataTransferObjects/WaiveTransactionObject.php @@ -16,17 +16,21 @@ class WaiveTransactionObject implements DataTransferObject /** @var int */ private $type; - public function __construct(int $id, string $billNo, int $type) + /** @var int */ + private $status; + + public function __construct(int $id, string $billNo, int $type, int $status) { $this->id = $id; $this->billNo = $billNo; $this->type = $type; + $this->status = $status; } /** * @return int */ - public function getId(): string + public function getId(): int { return $this->id; } @@ -42,8 +46,16 @@ class WaiveTransactionObject implements DataTransferObject /** * @return int */ - public function getType(): string + public function getType(): int { return $this->type; } + + /** + * @return int + */ + public function getStatus(): int + { + return $this->status; + } } diff --git a/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php b/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php index 1c4a45b3..d7a80ef3 100644 --- a/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php +++ b/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php @@ -18,6 +18,7 @@ class WaiveTransactionValidation extends AbstractValidation 'id' => $object->getId(), 'billNo' => $object->getBillNo(), 'type' => $object->getType(), + 'status' => $object->getStatus(), ]; } @@ -28,6 +29,7 @@ class WaiveTransactionValidation extends AbstractValidation return [ 'id' => 'required', 'type' => ['required', 'numeric', 'in:16'], //Only storage invoice (type 16) can be waived + 'status' => ['required', 'numeric', 'in:2'], //Approve storage invoice only, paid invoice stricly forbidden // 'billNo' => 'required', ]; } diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue index 4d294cf1..4c36d17b 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue @@ -69,7 +69,7 @@
- + Waive Transaction @@ -78,7 +78,7 @@ N/A - +
From d807e5d4fda880b58aa33d7ce44fbf98a07a67e5 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 15 Feb 2024 21:21:08 +0800 Subject: [PATCH 50/89] User interface to allow admin to waive warehouse storage invoice transaction --- .../elements/CustomerPaymentsBillingVariant2Component.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue index 4c36d17b..dd73291f 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue @@ -69,7 +69,7 @@
- + Waive Transaction @@ -78,7 +78,7 @@ N/A - +
From 78573db17d6c57b20882180570be6d6f0c98a712 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 18 Feb 2024 10:00:35 +0800 Subject: [PATCH 51/89] User interface to allow admin to update company whether is a credit term customer for warehoue storage charges --- .../UpdateCompanyCreditTermStatusLogic.php | 71 +++++++++++++++++++ .../UpdatesCompanyModuleIsCreditTerm.php | 23 ++++++ .../ListTransactionsLogic.php | 7 +- ...pdateCompanyCreditTermStatusController.php | 20 ++++++ app/Http/Resources/CompanyResource.php | 3 +- .../elements/CustomerProfileComponent.vue | 28 ++++++-- .../UpdateCreditTermStatusFormComponent.vue | 40 +++++++++++ routes/company.php | 1 + 8 files changed, 186 insertions(+), 7 deletions(-) create mode 100644 app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php create mode 100644 app/Classes/Modules/Companies/Services/UpdatesCompanyModuleIsCreditTerm.php create mode 100644 app/Http/Controllers/Companies/UpdateCompanyCreditTermStatusController.php create mode 100644 resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php new file mode 100644 index 00000000..a37d66ce --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php @@ -0,0 +1,71 @@ + 'Update Company Credit Term Status', + 'message' => 'You have successfully updated Company Credit Term Status' + ]; + } + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** @var UpdatesCompanyModuleIsCreditTerm */ + private $updatesCompanyModuleIsCreditTerm; + + + /** + * UpdateCompanyCreditTermStatusLogic constructor. + * @param FetchesCompany $fetchesCompany + * @param UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm + */ + public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm) + { + $this->fetchesCompany = $fetchesCompany; + $this->updatesCompanyModuleIsCreditTerm = $updatesCompanyModuleIsCreditTerm; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + + $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); + + $isCreditTerm = $company->companyModules()->first()->connections()->first()->is_credit_term; + + if ($isCreditTerm == 1) { + $isCreditTerm = 0; + } else { + $isCreditTerm = 1; + } + + $this->updatesCompanyModuleIsCreditTerm->execute($company->companyModules()->first()->connections()->first(), $isCreditTerm); + Log::info(Auth::user()->email." updated credit term status for customer with id: " .$request->route('id'). " to status " . $isCreditTerm); + + $result = ['is_credit_term' => $isCreditTerm]; + return $this->response(['data' => $result]); + } +} diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompanyModuleIsCreditTerm.php b/app/Classes/Modules/Companies/Services/UpdatesCompanyModuleIsCreditTerm.php new file mode 100644 index 00000000..2a0b24fb --- /dev/null +++ b/app/Classes/Modules/Companies/Services/UpdatesCompanyModuleIsCreditTerm.php @@ -0,0 +1,23 @@ +is_credit_term = $isCreditTerm; + + return $this->handler($model); + } +} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php index 5b362147..ae638bae 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Transactions\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Transactions\Services\ListsTransactions; use App\Http\Resources\TransactionWithStorageResource; +use App\Http\Resources\TransactionResource; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; @@ -49,8 +50,10 @@ class ListTransactionsLogic extends AbstractControllerLogic }); $item['storages'] = $filteredStorages; } + return $this->collectionResponse(TransactionWithStorageResource::collection($query)); + } + else{ + return $this->collectionResponse(TransactionResource::collection($query)); } - - return $this->collectionResponse(TransactionWithStorageResource::collection($query)); } } diff --git a/app/Http/Controllers/Companies/UpdateCompanyCreditTermStatusController.php b/app/Http/Controllers/Companies/UpdateCompanyCreditTermStatusController.php new file mode 100644 index 00000000..d41ca64a --- /dev/null +++ b/app/Http/Controllers/Companies/UpdateCompanyCreditTermStatusController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index 4590f46b..d969ac0d 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -21,7 +21,7 @@ class CompanyResource extends JsonResource { $companyModule = $this->companyModules()->first(); $companyTypeArray = CompanyType::COMPANY_TYPE_ID; - + return [ 'id' => $this->id, 'hash_id' => Crypt::encryptString($this->id), @@ -33,6 +33,7 @@ class CompanyResource extends JsonResource 'business_type' => (int) $this->business_type, 'status' => (int) $this->status, 'segments' => SegmentResource::collection($companyModule->connections()->first()->segments), + 'is_credit_term' => $companyModule->connections()->first()->is_credit_term, 'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())), 'employee' => new UserResource($companyModule->employees()->first()), 'company_module' => new CompanyModuleResource($companyModule), diff --git a/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue b/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue index 69625c6a..3c8aae23 100644 --- a/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue +++ b/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue @@ -17,7 +17,7 @@
- {{item.name}} + {{item.name}}
@@ -35,6 +35,26 @@
+
+
+
+
+
+ Credit term customer: YES +
+
+ Credit term customer: NO +
+
+
+ +
+ + + +
+
+
@@ -95,13 +115,13 @@
-
Company Type
+
Company Type
@@ -216,4 +236,4 @@ }, mixins: [componentHandler] } - \ No newline at end of file + diff --git a/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue b/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue new file mode 100644 index 00000000..a36263c3 --- /dev/null +++ b/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue @@ -0,0 +1,40 @@ + + diff --git a/routes/company.php b/routes/company.php index 362b735f..b9b8c213 100644 --- a/routes/company.php +++ b/routes/company.php @@ -9,6 +9,7 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update'); Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete'); Route::put('/name-and-debtor/update/{id}', 'UpdateCompanyNameAndDebtorController@update')->name('update.nameAndDebtor'); + Route::post('/update-credit-term/{id}', 'UpdateCompanyCreditTermStatusController@update')->name('update.creditterm.status'); Route::put('/type/update/{id}', 'UpdateCompanyTypeController@create')->name('update.type'); Route::post('/team/create', 'AddNewMemberController@create')->name('team.create'); From 02cb21bd5aab059020ef6a86ade89b084a4e7a87 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 18 Feb 2024 10:10:57 +0800 Subject: [PATCH 52/89] User interface to allow admin to update company whether is a credit term customer for warehoue storage charges --- .../companies/forms/UpdateCreditTermStatusFormComponent.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue b/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue index a36263c3..0a2f95b3 100644 --- a/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue @@ -29,7 +29,6 @@ export default { methods: { successHandler(response){ - console.log('update', response.payload.data); this.$emit('update', response.payload.data); this.closeModal(); this.formHandler(); From 62191c2711fdd9287a33f3e9beb2d14b05880d58 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 23 Feb 2024 10:49:09 +0800 Subject: [PATCH 53/89] Undo a changes made on previous commit --- .../ControllersLogic/ListTransactionsLogic.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php index ae638bae..5974f5e2 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php @@ -50,10 +50,11 @@ class ListTransactionsLogic extends AbstractControllerLogic }); $item['storages'] = $filteredStorages; } - return $this->collectionResponse(TransactionWithStorageResource::collection($query)); - } - else{ - return $this->collectionResponse(TransactionResource::collection($query)); + //return $this->collectionResponse(TransactionWithStorageResource::collection($query)); } + // else{ + // return $this->collectionResponse(TransactionResource::collection($query)); + // + return $this->collectionResponse(TransactionWithStorageResource::collection($query)); } } From 2689296a2c7bea0b6312dd018a275044b8d7d361 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 23 Feb 2024 11:09:30 +0800 Subject: [PATCH 54/89] Implement authorization module for update customer credit term status --- .../UpdateCompanyCreditTermStatusLogic.php | 9 +++- .../Rules/CanUpdateCompanyModule.php | 53 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 app/Classes/Modules/Companies/Standards/Rules/CanUpdateCompanyModule.php diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php index a37d66ce..9d0689a4 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Companies\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Services\FetchesCompany; use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleIsCreditTerm; +use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompanyModule; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -30,16 +31,20 @@ class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic /** @var UpdatesCompanyModuleIsCreditTerm */ private $updatesCompanyModuleIsCreditTerm; + /** @var CanUpdateCompanyModule */ + private $canUpdateCompanyModule; /** * UpdateCompanyCreditTermStatusLogic constructor. * @param FetchesCompany $fetchesCompany * @param UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm + * @param CanUpdateCompanyModule $canUpdateCompanyModule */ - public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm) + public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule) { $this->fetchesCompany = $fetchesCompany; $this->updatesCompanyModuleIsCreditTerm = $updatesCompanyModuleIsCreditTerm; + $this->canUpdateCompanyModule = $canUpdateCompanyModule; } /** @@ -51,9 +56,9 @@ class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { + $this->canUpdateCompanyModule->passes(); $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); - $isCreditTerm = $company->companyModules()->first()->connections()->first()->is_credit_term; if ($isCreditTerm == 1) { diff --git a/app/Classes/Modules/Companies/Standards/Rules/CanUpdateCompanyModule.php b/app/Classes/Modules/Companies/Standards/Rules/CanUpdateCompanyModule.php new file mode 100644 index 00000000..64f827fa --- /dev/null +++ b/app/Classes/Modules/Companies/Standards/Rules/CanUpdateCompanyModule.php @@ -0,0 +1,53 @@ +user(); + if($user){ + $roleToCheck = Auth()->user()->type; + if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) { + return true; + } + } + + return false; + } + + /** + * @param $object + * @return bool + * @throws \App\Classes\Exceptions\RequestValidationException + */ + protected function validators($object): bool + { + return true; + } + + /** + * @param CompanyObject $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } +} From b66dfa8649ac80c7efeba675b9d719edc69fdff9 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 24 Feb 2024 10:08:24 +0800 Subject: [PATCH 55/89] Implement authorization module for update customer credit term status --- .../Transactions/ControllersLogic/ListTransactionsLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php index 5974f5e2..2d5c40dd 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php @@ -43,7 +43,7 @@ class ListTransactionsLogic extends AbstractControllerLogic $query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters'))); if($request->input('storages')){ - foreach ($query->items() as &$item) { + foreach ($query->items() as $item) { $transactionId = $item['id']; $filteredStorages = array_filter($request->input('storages'), function ($storage) use ($transactionId) { return isset($storage['parentInvoiceId']) && $storage['parentInvoiceId'] == $transactionId; From aaae8bcafa0b897ed09f166872c070bdc64ab704 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 24 Feb 2024 10:48:26 +0800 Subject: [PATCH 56/89] Create a regenerate storage invoice feature to debug problem in reading and downloading storage invoice --- ...teSingleStorageInvoiceTransactionLogic.php | 58 ++++++++++++++++++ .../Rules/CanRegenerateStorageInvoice.php | 47 +++++++++++++++ ...gleStorageInvoiceTransactionController.php | 21 +++++++ ...stomerPaymentsBillingVariant2Component.vue | 60 +++++++++++++++---- routes/transaction.php | 1 + 5 files changed, 174 insertions(+), 13 deletions(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleStorageInvoiceTransactionLogic.php create mode 100644 app/Classes/Modules/Transactions/Standards/Rules/CanRegenerateStorageInvoice.php create mode 100644 app/Http/Controllers/Transactions/RegenerateSingleStorageInvoiceTransactionController.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleStorageInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleStorageInvoiceTransactionLogic.php new file mode 100644 index 00000000..51166015 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleStorageInvoiceTransactionLogic.php @@ -0,0 +1,58 @@ + 'Regenerate Storage Invoice', + 'message' => 'You have successfully regenerated storage invoice' + ]; + } + + + /** @var FetchesTransaction */ + private $fetchesTransaction; + + /** @var CreateStorageInvoiceDocTransactionFixProcessor */ + private $createStorageInvoiceDocTransactionProcessor; + + /** @var CanRegenerateStorageInvoice */ + private $canRegenerateStorageInvoice; + + /** + * @param CreatesDocument $createsDocument + */ + public function __construct(FetchesTransaction $fetchesTransaction, CreateStorageInvoiceDocTransactionFixProcessor $createStorageInvoiceDocTransactionProcessor, CanRegenerateStorageInvoice $canRegenerateStorageInvoice) + { + $this->fetchesTransaction = $fetchesTransaction; + $this->createStorageInvoiceDocTransactionProcessor = $createStorageInvoiceDocTransactionProcessor; + $this->canRegenerateStorageInvoice = $canRegenerateStorageInvoice; + } + + public function logic(Request $request) : JsonResponse + { + $this->canRegenerateStorageInvoice->passes(); + + $invoice = $this->fetchesTransaction->execute(['id' => $request->route('invoice_id')]); + $packingList = $invoice->owner; + + $this->createStorageInvoiceDocTransactionProcessor->execute($packingList, true); + + return $this->response([]); + } + +} diff --git a/app/Classes/Modules/Transactions/Standards/Rules/CanRegenerateStorageInvoice.php b/app/Classes/Modules/Transactions/Standards/Rules/CanRegenerateStorageInvoice.php new file mode 100644 index 00000000..d7a7a9bf --- /dev/null +++ b/app/Classes/Modules/Transactions/Standards/Rules/CanRegenerateStorageInvoice.php @@ -0,0 +1,47 @@ +user(); + if($user){ + $roleToCheck = Auth()->user()->type; + if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) { + return true; + } + } + + return false; + } + + /** + * @param $object + * @return bool + * @throws \App\Classes\Exceptions\RequestValidationException + */ + protected function validators($object): bool + { + return true; + } + + /** + * @param $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} diff --git a/app/Http/Controllers/Transactions/RegenerateSingleStorageInvoiceTransactionController.php b/app/Http/Controllers/Transactions/RegenerateSingleStorageInvoiceTransactionController.php new file mode 100644 index 00000000..0edebadd --- /dev/null +++ b/app/Http/Controllers/Transactions/RegenerateSingleStorageInvoiceTransactionController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue index dd73291f..cb589896 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue @@ -41,7 +41,21 @@
-
+
+ + Waive Transaction + + + Transaction Waived + + + N/A + + + + +
+
Billing Question?
@@ -68,21 +82,41 @@
-
- - Waive Transaction +
+ + + - - Transaction Waived + + - - N/A - - - + + + + -
-
+ + + + + + diff --git a/routes/transaction.php b/routes/transaction.php index caa5b6fb..9e41455c 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -11,6 +11,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::put('{id}/status/update/{status}', 'UpdateTransactionStatusController@update')->where('status', 'approve|expire|reject')->name('update'); route::post('/{invoice_id}/regenerate', 'RegenerateSingleShippingInvoiceTransactionController@regenerate')->name('invoice.regenerate'); Route::post('/waive/{id}', 'WaiveTransactionController@waive')->name('waive'); + Route::post('/storage-invoice/{invoice_id}/regenerate', 'RegenerateSingleStorageInvoiceTransactionController@regenerate')->name('storage.invoice.regenerate'); Route::get('wallet/list', 'ListWalletTransactionsController@list')->name('wallet.list'); From 2dc037c8fdb0c8044218cadd58f5b24b14087869 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 24 Feb 2024 11:08:19 +0800 Subject: [PATCH 57/89] Create a regenerate storage invoice feature to debug problem in reading and downloading storage invoice --- .../elements/CustomerPaymentsBillingVariant2Component.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue index cb589896..888b4cb5 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue @@ -41,7 +41,7 @@
-
+
Waive Transaction @@ -84,10 +84,10 @@
- - + + - + From f949877a7fa4f12684d81ad950b56477ff19f66f Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 24 Feb 2024 11:40:51 +0800 Subject: [PATCH 58/89] Create a regenerate storage invoice feature to debug problem in reading and downloading storage invoice --- .../RegenerateSingleStorageInvoiceTransactionLogic.php | 9 +++++++++ .../CustomerPaymentsBillingVariant2Component.vue | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleStorageInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleStorageInvoiceTransactionLogic.php index 51166015..3ea0a2ac 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleStorageInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/RegenerateSingleStorageInvoiceTransactionLogic.php @@ -10,6 +10,9 @@ use App\Classes\Modules\Documents\Services\CreatesDocument; use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionFixProcessor; use App\Classes\Modules\Transactions\Standards\Rules\CanRegenerateStorageInvoice; +use App\Classes\ValueObjects\Constants\TransactionType; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Log; class RegenerateSingleStorageInvoiceTransactionLogic extends AbstractControllerLogic { @@ -49,8 +52,14 @@ class RegenerateSingleStorageInvoiceTransactionLogic extends AbstractControllerL $invoice = $this->fetchesTransaction->execute(['id' => $request->route('invoice_id')]); $packingList = $invoice->owner; + $order = $packingList->owner; + $invoices = $order->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->get(); + foreach ($invoices as $invoice){ + $invoice->documents()->delete(); + } $this->createStorageInvoiceDocTransactionProcessor->execute($packingList, true); + Log::info(Auth::user()->email." regenerate storage invoice for transaction with id ".$request->route('invoice_id')); return $this->response([]); } diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue index 888b4cb5..cf9b05ec 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue @@ -85,7 +85,7 @@
- + From 41e1c346f642b8dbb706039e42b838c281f70861 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 25 Feb 2024 13:13:09 +0800 Subject: [PATCH 59/89] Rename a component --- .../orders/sections/OrderProfileV2SectionComponent.vue | 2 +- ...nent.vue => CustomerPaymentsBillingWithStorageComponent.vue} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename resources/assets/vue/components/paymentsBilling/elements/{CustomerPaymentsBillingVariant2Component.vue => CustomerPaymentsBillingWithStorageComponent.vue} (100%) diff --git a/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue b/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue index ed2e2e57..fd3276bd 100644 --- a/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue +++ b/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue @@ -149,7 +149,7 @@
- +
diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue similarity index 100% rename from resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingVariant2Component.vue rename to resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue From 1acc02eb938417f213eac448e79b387d9fb90a6f Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 25 Feb 2024 13:52:22 +0800 Subject: [PATCH 60/89] UI Update (Payment and Billing page) on Admin view to see shipping invoices with storage invoices on Pending Payment tab and Paid Invoice tab --- .../ListPackingListsLogic.php | 13 +- app/Http/Kernel.php | 1 + .../CheckForStorageInvoiceByPackingLists.php | 67 ++++ .../PackingListWithStorageResource.php | 56 +++ ...dminPaymentsBillingWithSearchComponent.vue | 3 +- ...minPaymentsBillingWithStorageComponent.vue | 293 ++++++++++++++++ ...PaymentsBillingWithoutStorageComponent.vue | 323 ++++++++++++++++++ ...gleParentAdminPaymentsBillingComponent.vue | 77 +++++ .../AdminPaymentsBillingSectionComponent.vue | 4 +- routes/packing_list.php | 3 +- 10 files changed, 833 insertions(+), 7 deletions(-) create mode 100644 app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php create mode 100644 app/Http/Resources/PackingListWithStorageResource.php create mode 100644 resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue create mode 100644 resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue create mode 100644 resources/assets/vue/components/paymentsBilling/elements/SingleParentAdminPaymentsBillingComponent.vue diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php index b9e3142d..1a63eb89 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php @@ -6,8 +6,8 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\PackingLists\Services\ListsPackingLists; use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists; -use App\Http\Resources\PackingListNullOrderResource; use App\Http\Resources\PackingListResource; +use App\Http\Resources\PackingListWithStorageResource; use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -54,7 +54,14 @@ class ListPackingListsLogic extends AbstractControllerLogic $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters'))); - return $this->collectionResponse(PackingListResource::collection($query)); + if($request->input('storages')){ + foreach ($query->items() as $item) { + $item['storages'] = $request->input('storages'); + } + return $this->collectionResponse(PackingListWithStorageResource::collection($query)); + } + else{ + return $this->collectionResponse(PackingListResource::collection($query)); + } } - } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index d458f7b1..fcd38fae 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -73,5 +73,6 @@ class Kernel extends HttpKernel 'storage.invoice.check.byorder' => \App\Http\Middleware\CheckForStorageInvoiceByOrderId::class, 'storage.invoice.check.bytransactions' => \App\Http\Middleware\CheckForStorageInvoiceByTransactions::class, 'storage.invoice.check.bygroup' => \App\Http\Middleware\CheckForStorageInvoiceByGroup::class, + 'storage.invoice.check.bypackinglists' => \App\Http\Middleware\CheckForStorageInvoiceByPackingLists::class, ]; } diff --git a/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php b/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php new file mode 100644 index 00000000..28588555 --- /dev/null +++ b/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php @@ -0,0 +1,67 @@ +storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor; + $this->listsPackingLists = $listsPackingLists; + } + + + /** + * Handle an incoming request. + * + * @param Request $request + * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse + */ + public function handle(Request $request, Closure $next) + { + $results = []; + $packinglists = null; + + $filters = json_decode($request->input('filters'), true); + // $filters['type_in'] = [TransactionType::SHIPPING_INVOICE]; + // if(json_encode($filters['order_by']) == '{"column":"id","DESC":true}'){ + // $filters['order_by_id_desc'] = true; + // } + // unset($filters['order_by']); + + if(isset($filters['check_for_storage_invoice'])){ + $packinglists = $this->listsPackingLists->execute($filters); + foreach($packinglists as $packingList){ + if($packingList){ + $order = $packingList->owner()->first(); + if($order instanceof Order){ + $storages = $this->storageInvoiceTransactionProcessor->executeOrder($order); + if($storages){ + $results = array_merge($results, $storages); + } + } + } + } + } + + $request->merge(['storages' => $results]); + + return $next($request); + } +} diff --git a/app/Http/Resources/PackingListWithStorageResource.php b/app/Http/Resources/PackingListWithStorageResource.php new file mode 100644 index 00000000..386af053 --- /dev/null +++ b/app/Http/Resources/PackingListWithStorageResource.php @@ -0,0 +1,56 @@ +user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]); + $packages = !$this->packingLists()->exists() || $exceptionUsers ? $this->packages : $this->packingLists->first()->packages; + $shippingTransaction = $this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first(); + $transactions = $this->transactions()->whereNotIn('transactions.status', [0, 1])->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get(); + $storages = []; + + if($this->storages){ + $transactionId = $shippingTransaction->id; + $filteredStorages = array_filter($this->storages, function ($storage) use ($transactionId) { + return isset($storage['parentInvoiceId']) && $storage['parentInvoiceId'] == $transactionId; + }); + $storages = $filteredStorages; + } + + return [ + 'id' => $this->id, + 'claimant_id' => $this->claimant_id, + 'reference' => $this->reference, + 'status' => $this->status, + 'transport' => new TransportResource($this->transports()->first()), + 'type' => $this->type, + 'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListResource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first())), + 'packages' => PackageResource::collection($packages), + $this->mergeWhen($this->owner instanceof Order, [ + 'order' => New OrderResource($this->owner) + ]), + 'shipping_transaction' => count($storages) == 0 ? new TransactionWithStorageResource($shippingTransaction): null, + 'storages' => $storages, + 'invoices' => TransactionWithStorageResource::collection($transactions), + 'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()), + ]; + } +} diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue index be4038bb..9b2cc71f 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue @@ -37,7 +37,8 @@ +
+

Total CBM

+
{{ (parseFloat(cbm) + parseFloat(overweight)).toFixed(3) }}
+
+
+
+
+ +
Invoice Details
+ + +
+
+

Subtotal

+
{{ item.shipping_transaction.amount - item.shipping_transaction.service_charge - item.shipping_transaction.tax }}
+
+
+

Service Charges

+
{{ item.shipping_transaction.service_charge }}
+
+
+

Tax

+
{{ item.shipping_transaction.tax }}
+
+
+

Total

+
{{ item.shipping_transaction.amount }}
+
+
+
+ +
+
+
+
+
+
+
+
+
Payment Attempt
+
+
+
+
+ +
+
+
+
+
+
+
+
+
Payment History
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
Total Amount:
+
+
+
MYR {{(Math.round((item.shipping_transaction.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
+
+
+
Paid Total:
+
+
+ +
Paid Total
+
+
+
+
+
Floating Amount:
+
+
+ +
Floating Amount
+
+
+
+
+
OutStanding Total:
+
+
+
MYR {{(Math.round((item.shipping_transaction.outstanding + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
+
+
+
Make Payment
+
+
+
+
+ + + +
+
+
+
+ + + + diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleParentAdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleParentAdminPaymentsBillingComponent.vue new file mode 100644 index 00000000..acf2ed18 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleParentAdminPaymentsBillingComponent.vue @@ -0,0 +1,77 @@ + + diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue index ee91d849..190ebe17 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue @@ -113,12 +113,12 @@
- +
- +
diff --git a/routes/packing_list.php b/routes/packing_list.php index 5282522a..dcee2dee 100644 --- a/routes/packing_list.php +++ b/routes/packing_list.php @@ -4,7 +4,8 @@ use Illuminate\Support\Facades\Route; Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' => 'packing_list'], function () { Route::get('/{id}/show', 'FetchPackingListController@fetch')->name('show'); - Route::get('/list', 'ListPackingListsController@list')->name('list'); + Route::get('/list', 'ListPackingListsController@list')->middleware('storage.invoice.check.bypackinglists')->name('list'); + // Route::get('/list', 'ListPackingListsController@list')->name('list'); Route::get('/list/job', 'ListPackingListsJobController@list')->name('list.job'); Route::post('/create', 'CreatePackingListController@create')->name('create'); Route::post('/create/deliver', 'CreateDeliverPackingListController@create')->name('create.deliver'); From eaa21beb8368c56e9b999967eaedfd0087723355 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 25 Feb 2024 14:04:19 +0800 Subject: [PATCH 61/89] UI Update (Payment and Billing page) on Admin view to see shipping invoices with storage invoices on Pending Payment tab and Paid Invoice tab --- app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php b/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php index 28588555..a393e3b5 100644 --- a/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php +++ b/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php @@ -5,6 +5,8 @@ namespace App\Http\Middleware; use Closure; use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor; use App\Classes\Modules\PackingLists\Services\ListsPackingLists; +use App\Classes\ValueObjects\Constants\TransactionType; +use App\Models\CompanyConnection; use App\Models\Order; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; @@ -43,9 +45,9 @@ class CheckForStorageInvoiceByPackingLists // if(json_encode($filters['order_by']) == '{"column":"id","DESC":true}'){ // $filters['order_by_id_desc'] = true; // } - // unset($filters['order_by']); if(isset($filters['check_for_storage_invoice'])){ + unset($filters['order_by']); $packinglists = $this->listsPackingLists->execute($filters); foreach($packinglists as $packingList){ if($packingList){ From 4179706e046fcdbfe8ca2164cd365163bf2af223 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 25 Feb 2024 14:26:54 +0800 Subject: [PATCH 62/89] UI Update (Payment and Billing page) on Admin view to see shipping invoices with storage invoices on Pending Payment tab and Paid Invoice tab --- .../SingleAdminPaymentsBillingWithStorageComponent.vue | 2 +- .../SingleAdminPaymentsBillingWithoutStorageComponent.vue | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue index 0afc6496..ce96d88f 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue @@ -20,7 +20,7 @@

Invoice Date

-
{{ singleInvoice.bill_no }}
+
({{ singleInvoice.bill_no }})
n/a
{{ singleInvoice.updated_at }}
diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue index 59b4d964..08751538 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue @@ -20,8 +20,9 @@

Invoice Date

+
({{ item.shipping_transaction.bill_no }})
n/a
-
{{ item.shipping_transaction.updated_at }}
+
{{ item.shipping_transaction.updated_at }}
From 141062a7bf2690ce0923ddc60ec502188f6aed9f Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 25 Feb 2024 15:21:04 +0800 Subject: [PATCH 63/89] Fix storage invoice not allow to be regenerated if not yet pay --- .../CustomerPaymentsBillingWithStorageComponent.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue index cf9b05ec..f48904d8 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue @@ -84,10 +84,13 @@
- + - + + + + From 09383a45a60c5c39d9909b6ab21e549bf81c6efe Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 25 Feb 2024 15:44:03 +0800 Subject: [PATCH 64/89] UI Update (Payment and Billing page) on Admin view to see shipping invoices with storage invoices on Pending Payment tab and Paid Invoice tab --- .../elements/SingleAdminPaymentsBillingWithStorageComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue index ce96d88f..15889fb2 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue @@ -1,7 +1,7 @@ diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue index 13df803e..a7017c1f 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchPollingComponent.vue @@ -34,15 +34,10 @@
- - diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue index 25e4c303..f790c3c6 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue @@ -113,12 +113,12 @@
- +
- +
From e97cbfa618eb131d59305568b871a3a8717a65c4 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 26 Feb 2024 16:36:43 +0800 Subject: [PATCH 66/89] Fix a problem with missing paid storage invoice when customer credit term status is updated --- ...heckStorageInvoiceTransactionProcessor.php | 78 +++++++++++++++---- .../Validators/WaiveTransactionValidation.php | 6 +- 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php index bc9adccd..06e8a292 100644 --- a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php @@ -103,29 +103,34 @@ class CheckStorageInvoiceTransactionProcessor $results = []; $marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; $is_credit_term = $order->companyModule->inviters()->withPivot('is_credit_term')->first()->pivot->is_credit_term; - if(!$is_credit_term){ - Log::channel('storage_invoices')->info('orderId: '.$order->id.', orderReference: '.$order->reference.', marking: '.$marking.', is_credit_term: '.$is_credit_term); - $packingLists = $order->destinationWarehousePackages; + Log::channel('storage_invoices')->info('orderId: '.$order->id.', orderReference: '.$order->reference.', marking: '.$marking.', is_credit_term: '.$is_credit_term); + $packingLists = $order->destinationWarehousePackages; - foreach ($packingLists as $packingList){ - $arrivalDateAtChinaWarehouse = $this->getArrivalDateAtChinaWarehoue($packingList); - Log::channel('storage_invoices')->info('arrivalDateAtChinaWarehouse: '.json_encode($arrivalDateAtChinaWarehouse)); - Log::channel('storage_invoices')->info('destinationWarehousePackage: '.json_encode($packingList)); - $eta = $this->getEtaFromPackingList($packingList); - if($arrivalDateAtChinaWarehouse && $eta){ - $transactions = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get(); - // $transactions = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->where('transactions.status', ApprovalStatus::APPROVED)->get(); + foreach ($packingLists as $packingList){ + $arrivalDateAtChinaWarehouse = $this->getArrivalDateAtChinaWarehoue($packingList); + Log::channel('storage_invoices')->info('arrivalDateAtChinaWarehouse: '.json_encode($arrivalDateAtChinaWarehouse)); + Log::channel('storage_invoices')->info('destinationWarehousePackage: '.json_encode($packingList)); + $eta = $this->getEtaFromPackingList($packingList); + if($arrivalDateAtChinaWarehouse && $eta){ + $transactions = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get(); + // $transactions = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->where('transactions.status', ApprovalStatus::APPROVED)->get(); - /** @var Transaction $invoice_transaction */ - foreach ($transactions as $invoice_transaction){ + /** @var Transaction $invoice_transaction */ + foreach ($transactions as $invoice_transaction){ + $result = null; + if(!$is_credit_term){ $result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta, $isBackDoorCheck); - if($result){ - $results[] = $result; - } + } + else{ + $result = $this->isPaidStorageInvoiceExist($invoice_transaction, $packingList, $eta); + } + if($result){ + $results[] = $result; } } } } + return $results; } @@ -266,6 +271,47 @@ class CheckStorageInvoiceTransactionProcessor } + private function isPaidStorageInvoiceExist($transaction, $destinationWarehousePackage, $eta){ + $pricePerCBM = 3; + $resultNumberOfDaysFree = 10; + $dt1 = $eta->copy()->addDay()->startOfDay(); + $resultStartDate = $dt1->format('Y-m-d'); + $currentDatetime = Carbon::now(); + $dt2 = $currentDatetime->copy()->addDay()->startOfDay(); + $resultCurrentDate = $dt2->format('Y-m-d H:i:s'); + $interval = Carbon::parse($dt2)->diff($dt1); + $resultNumberOfDaysExceeded = $interval->days - $resultNumberOfDaysFree; + $paidStorageInvoice = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('transactions.status', [ApprovalStatus::COMPLETED])->first(); + if($paidStorageInvoice){ + $storageInvoiceId = $paidStorageInvoice->id; + $transactionDetailsItems = $transaction->transactionDetails()->get(); + $cbm = 0.00; + foreach ($transactionDetailsItems as $tdItem){ + $quantity = $tdItem->quantity; + if($tdItem->price < 0.00){ + $quantity = $quantity * -1; + } + $cbm = $cbm + $quantity; + } + + if($storageInvoiceId !== 0){ + $result = [ + 'parentInvoiceId' => $transaction->id, + 'storageInvoiceId' => $storageInvoiceId, + 'numberOfDaysExceeded' => $resultNumberOfDaysExceeded, + 'numberOfDaysFree' => $resultNumberOfDaysFree, + 'startDate' => $resultStartDate, + 'currentDate' => $resultCurrentDate, + 'cbm' => $cbm, + 'pricePerCBM' => $pricePerCBM, + 'storageInvoice' => new TransactionWithStorageResource($paidStorageInvoice) + ]; + return $result; + } + } + return []; + } + private function updatePaymentTransactionViaGroupPayment($storageInvoice){ Log::channel('storage_invoices')->info('updatePaymentTransactionViaGroupPayment'); $groups = $storageInvoice->groups()->get(); diff --git a/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php b/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php index d7a80ef3..b6de888b 100644 --- a/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php +++ b/app/Classes/Modules/Transactions/Standards/Validators/WaiveTransactionValidation.php @@ -5,6 +5,8 @@ namespace App\Classes\Modules\Transactions\Standards\Validators; use App\Classes\General\Abstracts\AbstractValidation; use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject; +use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\ValueObjects\Constants\TransactionType; class WaiveTransactionValidation extends AbstractValidation { @@ -28,8 +30,8 @@ class WaiveTransactionValidation extends AbstractValidation protected function rules(): array { return [ 'id' => 'required', - 'type' => ['required', 'numeric', 'in:16'], //Only storage invoice (type 16) can be waived - 'status' => ['required', 'numeric', 'in:2'], //Approve storage invoice only, paid invoice stricly forbidden + 'type' => ['required', 'numeric', 'in:'.TransactionType::STORAGE_INVOICE], //Only storage invoice (type 16) can be waived + 'status' => ['required', 'numeric', 'in:'.ApprovalStatus::APPROVED], //Approve storage invoice only, paid invoice stricly forbidden // 'billNo' => 'required', ]; } From 5e636862bb5b6c58e745826ad8ba07f074748add Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 27 Feb 2024 21:31:14 +0800 Subject: [PATCH 67/89] check if the address district name is null --- .../orders/sections/OrderProfileV2SectionComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue b/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue index fd3276bd..65c1bcce 100644 --- a/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue +++ b/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue @@ -79,7 +79,7 @@
Delivery Address: 
-
{{order.address.reference}}
+
{{order.address.reference}}
From 5c6418cb1f6a5f790d99e46589990cdbb7770480 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 29 Feb 2024 16:30:57 +0800 Subject: [PATCH 68/89] When customer isCreditTerm status is updated to true, all existing storage invoices that is not paid but approve will be deleted --- .../UpdateCompanyCreditTermStatusLogic.php | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php index 9d0689a4..a319173d 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php @@ -7,6 +7,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Services\FetchesCompany; use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleIsCreditTerm; use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompanyModule; +use App\Classes\Modules\Transactions\Services\ListsTransactions; +use App\Classes\ValueObjects\Constants\TransactionType; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -34,17 +36,23 @@ class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic /** @var CanUpdateCompanyModule */ private $canUpdateCompanyModule; + /** @var ListsTransactions */ + private $listsTransactions; + + /** * UpdateCompanyCreditTermStatusLogic constructor. * @param FetchesCompany $fetchesCompany * @param UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm * @param CanUpdateCompanyModule $canUpdateCompanyModule + * @param ListsTransactions $listsTransactions */ - public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule) + public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule, ListsTransactions $listsTransactions) { $this->fetchesCompany = $fetchesCompany; $this->updatesCompanyModuleIsCreditTerm = $updatesCompanyModuleIsCreditTerm; $this->canUpdateCompanyModule = $canUpdateCompanyModule; + $this->listsTransactions = $listsTransactions; } /** @@ -59,7 +67,8 @@ class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic $this->canUpdateCompanyModule->passes(); $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); - $isCreditTerm = $company->companyModules()->first()->connections()->first()->is_credit_term; + $companyModule = $company->companyModules()->first(); + $isCreditTerm = $companyModule->connections()->first()->is_credit_term; if ($isCreditTerm == 1) { $isCreditTerm = 0; @@ -67,6 +76,21 @@ class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic $isCreditTerm = 1; } + if($isCreditTerm === 1){ + //{"per_page":10,"order_by":{"column":"id","DESC":true},"status_in":[2],"receiver":190,"type_in":[1],"does_not_have_payment_status_in":[0,1],"does_not_have_groups":1,"check_for_storage_invoice":1} + + $filters = [ + 'status_in' => [2], + 'receiver' => $companyModule->id, + 'type_in' => [TransactionType::STORAGE_INVOICE] + ]; + + $transactions = $this->listsTransactions->execute($filters); + foreach($transactions as $transaction){ + $transaction->delete(); + } + } + $this->updatesCompanyModuleIsCreditTerm->execute($company->companyModules()->first()->connections()->first(), $isCreditTerm); Log::info(Auth::user()->email." updated credit term status for customer with id: " .$request->route('id'). " to status " . $isCreditTerm); From 03c5ced77bd04c4d9e99fb767e991addd6454f37 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 29 Feb 2024 16:32:37 +0800 Subject: [PATCH 69/89] Remove code no longer necessary - isBackDoorCheck flag --- .../ControllersLogic/CallbackBillplzLogic.php | 2 +- ...heckStorageInvoiceTransactionProcessor.php | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php index a9f94410..d094ef74 100644 --- a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php @@ -145,7 +145,7 @@ class CallbackBillplzLogic $pL = $invoice->owner; $order = $pL->owner; if($order){ - $this->storageInvoiceTransactionProcessor->executeOrder($order, false); //original was set true here so that no group is soft deleted or billplz bill got deleted + $this->storageInvoiceTransactionProcessor->executeOrder($order); } } } diff --git a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php index 06e8a292..d3eed95e 100644 --- a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php @@ -99,7 +99,7 @@ class CheckStorageInvoiceTransactionProcessor return $this->executeOrder($order); } - public function executeOrder(Order $order, bool $isBackDoorCheck = false){ + public function executeOrder(Order $order){ $results = []; $marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; $is_credit_term = $order->companyModule->inviters()->withPivot('is_credit_term')->first()->pivot->is_credit_term; @@ -119,7 +119,7 @@ class CheckStorageInvoiceTransactionProcessor foreach ($transactions as $invoice_transaction){ $result = null; if(!$is_credit_term){ - $result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta, $isBackDoorCheck); + $result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta); } else{ $result = $this->isPaidStorageInvoiceExist($invoice_transaction, $packingList, $eta); @@ -172,7 +172,7 @@ class CheckStorageInvoiceTransactionProcessor return null; } - private function processSingleTransactionOfTypeShippingInvoice($transaction, $destinationWarehousePackage, $company_module_id, $eta, $isBackDoorCheck){ + private function processSingleTransactionOfTypeShippingInvoice($transaction, $destinationWarehousePackage, $company_module_id, $eta){ $pricePerCBM = 3; $resultNumberOfDaysFree = 10; $dt1 = $eta->copy()->addDay()->startOfDay(); @@ -232,14 +232,14 @@ class CheckStorageInvoiceTransactionProcessor 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); - } - else{ - $this->updatePaymentTransactionViaGroupPayment($storageInvoice); - } + // if(!$isBackDoorCheck){ + if(count($paymentTransactions) > 0){ + $this->updatePaymentTransactionViaNonGroupPayment($paymentTransactions); } + else{ + $this->updatePaymentTransactionViaGroupPayment($storageInvoice); + } + //} $proceedToUpdate = true; } From a442c7815619cddb9b78a925f9c13cca7bdba541 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 29 Feb 2024 17:19:17 +0800 Subject: [PATCH 70/89] Refresh page after a payment transaction is suspended/deleted --- .../forms/DeletePaymentAttemptFormComponent.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue index f3248ed8..9feeda60 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue @@ -27,6 +27,15 @@ import componentHandler from '../../../general/mixins/componentHandler'; import ModalFormHandler from '../../../general/mixins/modalFormHandler'; export default { + methods:{ + successHandler(response){ + this.closeModal(); + this.formHandler(); + if(response.payload.data.id){ + window.location.reload(); + } + }, + }, mixins: [componentHandler, ModalFormHandler] } From c9998029b037dbbafdb02c64a56d5963b82e7212 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 29 Feb 2024 21:10:37 +0800 Subject: [PATCH 71/89] Fix a non functioning group payment delete at order page meant for shipping invoice with storage invoice --- ...roupPaymentTransactionDetailsComponent.vue | 5 ++- ...DeleteGroupPaymentAttemptFormComponent.vue | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 resources/assets/vue/components/paymentsBilling/forms/DeleteGroupPaymentAttemptFormComponent.vue diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleGroupPaymentTransactionDetailsComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleGroupPaymentTransactionDetailsComponent.vue index 621f9bcc..b2db1dfa 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/SingleGroupPaymentTransactionDetailsComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleGroupPaymentTransactionDetailsComponent.vue @@ -34,7 +34,7 @@ - + @@ -55,10 +55,12 @@ bank_id: 1 }, section: 'bookingDetailSection', + groupId: 0, } }, mounted() { this.item.id = this.item.payment_transaction.id; + this.groupId = this.item && this.item.transactions_ids && this.item.transactions_ids.length > 0 ? this.item.transactions_ids[0].group_id : 0; }, methods: { clickExpand(){ @@ -71,3 +73,4 @@ mixins: [componentHandler] } + diff --git a/resources/assets/vue/components/paymentsBilling/forms/DeleteGroupPaymentAttemptFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/DeleteGroupPaymentAttemptFormComponent.vue new file mode 100644 index 00000000..85b6121f --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/DeleteGroupPaymentAttemptFormComponent.vue @@ -0,0 +1,40 @@ + + From f191979a53d352a0e7b0b65cd2681590687e4219 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 29 Feb 2024 22:28:18 +0800 Subject: [PATCH 72/89] Hide 'Your Payment Proof' at the order page when does not need to appear --- .../elements/PaymentHistoryComponent.vue | 14 +++++++++----- ...upPaymentHistoryTransactionDetailsComponent.vue | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue index c09d9334..ec886b13 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue @@ -50,10 +50,10 @@ - -
+
From 24a4d269b339d7f0bec9a3f1ea24d45124ae63ac Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 1 Mar 2024 11:27:46 +0800 Subject: [PATCH 73/89] add edmond in the permits reminder email --- app/Console/Commands/SendPermitsReminderEmails.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/SendPermitsReminderEmails.php b/app/Console/Commands/SendPermitsReminderEmails.php index c81df2f7..15d4e626 100644 --- a/app/Console/Commands/SendPermitsReminderEmails.php +++ b/app/Console/Commands/SendPermitsReminderEmails.php @@ -54,7 +54,7 @@ class SendPermitsReminderEmails extends Command $users = User::whereIn( 'email', [ - // 'edmond.wuiming2021@gmail.com', + 'edmond.wuiming2021@gmail.com', 'anithagurl96@gmail.com' ] )->get(); From 00bf7c0cf4cb6832e2791ebddac33e0eabcff44e Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 1 Mar 2024 11:47:21 +0800 Subject: [PATCH 74/89] Fix when customer isCreditTerm is updated, waive storage invoices instead of deleting it --- .../UpdateCompanyCreditTermStatusLogic.php | 25 +++++++++++++++++-- ...heckStorageInvoiceTransactionProcessor.php | 24 ++++++++++++++---- .../UpdateCreditTermStatusFormComponent.vue | 2 +- .../GroupPaymentsBillingComponents.vue | 2 +- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php index a319173d..ff57b814 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyCreditTermStatusLogic.php @@ -8,7 +8,10 @@ use App\Classes\Modules\Companies\Services\FetchesCompany; use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleIsCreditTerm; use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompanyModule; use App\Classes\Modules\Transactions\Services\ListsTransactions; +use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived; +use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor; use App\Classes\ValueObjects\Constants\TransactionType; +use App\Models\Order; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -39,20 +42,31 @@ class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic /** @var ListsTransactions */ private $listsTransactions; + /** @var UpdatesTransactionIsWaived */ + private $updatesTransactionIsWaived; + + /** @var CheckStorageInvoiceTransactionProcessor */ + private $storageInvoiceTransactionProcessor; + + /** * UpdateCompanyCreditTermStatusLogic constructor. * @param FetchesCompany $fetchesCompany * @param UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm * @param CanUpdateCompanyModule $canUpdateCompanyModule + * @param UpdatesTransactionIsWaived $updatesTransactionIsWaived * @param ListsTransactions $listsTransactions + * @param CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor */ - public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule, ListsTransactions $listsTransactions) + public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule, UpdatesTransactionIsWaived $updatesTransactionIsWaived, ListsTransactions $listsTransactions, CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor) { $this->fetchesCompany = $fetchesCompany; $this->updatesCompanyModuleIsCreditTerm = $updatesCompanyModuleIsCreditTerm; $this->canUpdateCompanyModule = $canUpdateCompanyModule; $this->listsTransactions = $listsTransactions; + $this->updatesTransactionIsWaived = $updatesTransactionIsWaived; + $this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor; } /** @@ -87,7 +101,14 @@ class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic $transactions = $this->listsTransactions->execute($filters); foreach($transactions as $transaction){ - $transaction->delete(); + $this->updatesTransactionIsWaived->execute($transaction); + $packingList = $transaction->owner()->first(); + if($packingList){ + $order = $packingList->owner()->first(); + if($order instanceof Order){ + $storages = $this->storageInvoiceTransactionProcessor->executeOrder($order); + } + } } } diff --git a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php index d3eed95e..d5c87ce0 100644 --- a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php @@ -122,7 +122,7 @@ class CheckStorageInvoiceTransactionProcessor $result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta); } else{ - $result = $this->isPaidStorageInvoiceExist($invoice_transaction, $packingList, $eta); + $result = $this->isPaidOrWaivedStorageInvoiceExist($invoice_transaction, $packingList, $eta); } if($result){ $results[] = $result; @@ -271,7 +271,7 @@ class CheckStorageInvoiceTransactionProcessor } - private function isPaidStorageInvoiceExist($transaction, $destinationWarehousePackage, $eta){ + private function isPaidOrWaivedStorageInvoiceExist($transaction, $packingList, $eta){ $pricePerCBM = 3; $resultNumberOfDaysFree = 10; $dt1 = $eta->copy()->addDay()->startOfDay(); @@ -281,9 +281,22 @@ class CheckStorageInvoiceTransactionProcessor $resultCurrentDate = $dt2->format('Y-m-d H:i:s'); $interval = Carbon::parse($dt2)->diff($dt1); $resultNumberOfDaysExceeded = $interval->days - $resultNumberOfDaysFree; - $paidStorageInvoice = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('transactions.status', [ApprovalStatus::COMPLETED])->first(); + $paidStorageInvoice = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('transactions.status', [ApprovalStatus::COMPLETED])->first(); if($paidStorageInvoice){ - $storageInvoiceId = $paidStorageInvoice->id; + $storageInvoice = $paidStorageInvoice; + } + else{ + $waivedStorageInvoice = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->where('transactions.is_waived', 1)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->first(); + $storageInvoice = $waivedStorageInvoice; + } + + if($storageInvoice){ + $storageInvoiceId = $storageInvoice->id; + + if(isset($storageInvoice->is_waived) && $storageInvoice->is_waived){ + $pricePerCBM = 0; + } + $transactionDetailsItems = $transaction->transactionDetails()->get(); $cbm = 0.00; foreach ($transactionDetailsItems as $tdItem){ @@ -304,11 +317,12 @@ class CheckStorageInvoiceTransactionProcessor 'currentDate' => $resultCurrentDate, 'cbm' => $cbm, 'pricePerCBM' => $pricePerCBM, - 'storageInvoice' => new TransactionWithStorageResource($paidStorageInvoice) + 'storageInvoice' => new TransactionWithStorageResource($storageInvoice) ]; return $result; } } + return []; } diff --git a/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue b/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue index 0a2f95b3..512678b0 100644 --- a/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/UpdateCreditTermStatusFormComponent.vue @@ -8,7 +8,7 @@
Update Credit Term Customer
Are you sure you want to update the credit term status for this company to {{ data.is_credit_term === 1 ? 'NO' : 'YES' }}?
- +

All existing invoices for storage that have not yet been paid will be waived

diff --git a/resources/assets/vue/components/paymentsBilling/elements/GroupPaymentsBillingComponents.vue b/resources/assets/vue/components/paymentsBilling/elements/GroupPaymentsBillingComponents.vue index 3d8a39ae..763f0174 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/GroupPaymentsBillingComponents.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/GroupPaymentsBillingComponents.vue @@ -85,7 +85,7 @@
- +
From b55e32aece4b6aff700600fb3a9352e22f325ad9 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 2 Mar 2024 13:26:46 +0800 Subject: [PATCH 75/89] Fix missing container info at admin payment and billing page --- ...minPaymentsBillingWithStorageComponent.vue | 1 + ...PaymentsBillingWithoutStorageComponent.vue | 1 + .../views/pages/paymentAndBilling2.blade.php | 131 ++++++++++++++++++ 3 files changed, 133 insertions(+) diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue index 15889fb2..dbec47a0 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue @@ -17,6 +17,7 @@

Container

{{item.packages[0].container.container_reference}}
+
{{item.container.container_reference}}

Invoice Date

diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue index 08751538..4a26c402 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue @@ -17,6 +17,7 @@

Container

{{item.packages[0].container.container_reference}}
+
{{item.container.container_reference}}

Invoice Date

diff --git a/resources/views/pages/paymentAndBilling2.blade.php b/resources/views/pages/paymentAndBilling2.blade.php index cf4f339f..ac1de6b2 100644 --- a/resources/views/pages/paymentAndBilling2.blade.php +++ b/resources/views/pages/paymentAndBilling2.blade.php @@ -1,5 +1,136 @@ @extends('layouts.base_portal') @section('inner_content') +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Payments
+
+
+
+
+
+ {{--
+
+
+
+
+ +
+
+
+
+
Refunds
+
+
+
+
+
--}} + {{--
+
+
+
+
+ +
+
+
+
+
Supplier Bills
+
+
+
+
+
--}} +
+
+
+
+
+
+
+ + + +
+
+
+
+ {{--
+
+
+
+ + + +
+
+
+
--}} +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Dispute
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
From 758498f48650238034e41956c6517cda5a94451d Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 2 Mar 2024 14:09:06 +0800 Subject: [PATCH 76/89] Fix a duplication problem in Pending Payment listing as a result of storage invoices --- ...ListLimitOneByTypeOrderedByInvoiceDate.php | 32 +++++++++++++++++++ ...PaymentsBillingPollingSectionComponent.vue | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/Classes/General/Eloquent/Filters/PackingListLimitOneByTypeOrderedByInvoiceDate.php diff --git a/app/Classes/General/Eloquent/Filters/PackingListLimitOneByTypeOrderedByInvoiceDate.php b/app/Classes/General/Eloquent/Filters/PackingListLimitOneByTypeOrderedByInvoiceDate.php new file mode 100644 index 00000000..a0316805 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/PackingListLimitOneByTypeOrderedByInvoiceDate.php @@ -0,0 +1,32 @@ +select('packing_lists.*')->join('transactions', function($join){ + $join->on('transactions.owner_id', '=', 'packing_lists.id'); + $join->where('transactions.owner_type', '=', PackingList::class); + $join->where('transactions.status', '=', ApprovalStatus::APPROVED); + $join->whereRaw('(transactions.type <> 16 OR transactions.id = ( + SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1 + ))'); + })->orderBy('transactions.updated_at', 'DESC'); + } + +} diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue index f790c3c6..a8315f55 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue @@ -113,7 +113,7 @@
- +
From 252636a7dff8d333b4d267a0a2dfe902a79c5dee Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 8 Mar 2024 08:46:05 +0800 Subject: [PATCH 77/89] Fix 404 exception caught at production laravel logs --- app/Http/Middleware/CheckForStorageInvoiceByOrderId.php | 7 ++++++- .../orders/sections/OrderProfileV2SectionComponent.vue | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Middleware/CheckForStorageInvoiceByOrderId.php b/app/Http/Middleware/CheckForStorageInvoiceByOrderId.php index 5765a284..c576da51 100644 --- a/app/Http/Middleware/CheckForStorageInvoiceByOrderId.php +++ b/app/Http/Middleware/CheckForStorageInvoiceByOrderId.php @@ -29,7 +29,12 @@ class CheckForStorageInvoiceByOrderId public function handle(Request $request, Closure $next) { $orderId = $request->route('id'); - $storages = $this->storageInvoiceTransactionProcessor->execute($orderId); + $storages = []; + try{ + $storages = $this->storageInvoiceTransactionProcessor->execute($orderId); + } catch (\Exception $exception) { + $storages = []; + } $request->merge(['storages' => $storages]); return $next($request); } diff --git a/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue b/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue index fd3276bd..de183861 100644 --- a/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue +++ b/resources/assets/vue/components/orders/sections/OrderProfileV2SectionComponent.vue @@ -215,6 +215,11 @@ this.isLoading = false; this.order = response.payload.data; }, + errorHandler(error, status){ + if(status == 404){ + window.location.href = this.route('error.404'); + } + }, getStorageInfo(invoice) { const storageObject = this.findStorageInfoObject(invoice.id); return storageObject; From 45a2544b9d1d1a1b67b01bf5e3eac23e568ea524 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 8 Mar 2024 20:43:38 +0800 Subject: [PATCH 78/89] Temporary disable manual payment at order page for invoices with storage fee --- .../elements/CustomerPaymentsBillingWithStorageComponent.vue | 2 +- .../paymentsBilling/forms/GroupPaymentFormComponent.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue index f48904d8..4c8c9538 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingWithStorageComponent.vue @@ -281,7 +281,7 @@
Make Payment
- +
diff --git a/resources/assets/vue/components/paymentsBilling/forms/GroupPaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/GroupPaymentFormComponent.vue index fea97285..9282c280 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/GroupPaymentFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/GroupPaymentFormComponent.vue @@ -55,7 +55,7 @@
-
+
{{$store.getters.isShowing('otherPaymentMethods') ? 'Hide' : 'Show'}} Alternative Methods
From 5565d0b39bf3dadb1e2af0911002a8c408639b07 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 9 Mar 2024 21:17:49 +0800 Subject: [PATCH 79/89] Update log location JobResourceNotFoundException --- app/Classes/General/Abstracts/AbstractControllerLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/General/Abstracts/AbstractControllerLogic.php b/app/Classes/General/Abstracts/AbstractControllerLogic.php index 48cde9cf..fa48166b 100644 --- a/app/Classes/General/Abstracts/AbstractControllerLogic.php +++ b/app/Classes/General/Abstracts/AbstractControllerLogic.php @@ -65,7 +65,7 @@ abstract class AbstractControllerLogic } catch (ErrorException|GeneralExceptions|TypeError $exception){ if ($exception instanceof JobResourceNotFoundException) { - Log::error(sprintf( + Log::channel('storage_invoices')->info(sprintf( "Uncaught exception '%s' with message '%s' in %s:%d", get_class($exception), $exception->getMessage(), From 27529e90caa561261304c4b5d2e86e1f9b920a36 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 12 Mar 2024 14:20:19 +0800 Subject: [PATCH 80/89] Fix a problem reported by Yien where order shipping invoice pending payment despite payment made --- ...imeTransactionFixBillplzFailedCallback.php | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/Console/Commands/OneTimeTransactionFixBillplzFailedCallback.php diff --git a/app/Console/Commands/OneTimeTransactionFixBillplzFailedCallback.php b/app/Console/Commands/OneTimeTransactionFixBillplzFailedCallback.php new file mode 100644 index 00000000..f015e41b --- /dev/null +++ b/app/Console/Commands/OneTimeTransactionFixBillplzFailedCallback.php @@ -0,0 +1,73 @@ +callbackBillplzProcessor = $callbackBillplzProcessor; + } + + /** + * Execute the console command. + * + * @return int + */ + public function handle() + { + ini_set('memory_limit', '-1'); + + $this->outputArray = []; + $start = new Carbon(); + + //This transaction, 15205 has approve payment but not its owner, shipping invoice + $transaction = Transaction::whereIn('id', [15205])->first(); + $this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 15205 cron started.'); + + if($transaction && $transaction->id == 15205){ + + $status = ApprovalStatus::APPROVED; + $this->callbackBillplzProcessor->execute($transaction, $status); + } + + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + $this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 15205 cron ended. ElapsedTime: ' . $elapsedTime); + } +} From 11e23900595213190641a60c250362a9640f3619 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 12 Mar 2024 23:52:07 +0800 Subject: [PATCH 81/89] update container and container remarks --- app/Http/Resources/ContainerResource.php | 20 +- .../forms/ContainerCommentFormComponent.vue | 4 +- .../ContainerProfileV2SectionComponent.vue | 229 ++++++++++++++++++ .../orders/elements/PackageComponent.vue | 44 +++- .../pages/templates/warehouseFlow.blade.php | 3 +- 5 files changed, 288 insertions(+), 12 deletions(-) create mode 100644 resources/assets/vue/components/containers/sections/ContainerProfileV2SectionComponent.vue diff --git a/app/Http/Resources/ContainerResource.php b/app/Http/Resources/ContainerResource.php index 49a33232..dd45412c 100644 --- a/app/Http/Resources/ContainerResource.php +++ b/app/Http/Resources/ContainerResource.php @@ -23,17 +23,25 @@ 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, + 'loading_date' => optional($this->loading_date)->format('d-m-Y'), 'transport' => new TransportResource($this->transports()->first()), 'packages_count' => $this->packages()->where('packages.type', '!=', 2)->sum('quantity'), 'total_cbm' => $this->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity')), 'remarks' => RemarkResource::collection($this->remarks), 'status' => $this->status, - 'packing_lists' => $this->whenLoaded('packingLists', PackingListResource::collection($this->whenLoaded('packingLists', function(){ - return $this->packingLists()->get()->sortBy(function ($packingList) { - return $packingList->owner->company_module_id; - }); - }))) + 'packing_lists' => $this->shouldIncludePackingListData($request) ? $this->getSortedPackingLists() : null, ]; } + + protected function shouldIncludePackingListData($request) + { + return (isset($request->all()['with_packing_list_data']) && ($request->all()['with_packing_list_data'] == false)) ? false : true; + } + + protected function getSortedPackingLists() + { + return $this->whenLoaded('packingLists', PackingListResource::collection( + $this->packingLists()->get()->sortBy(fn ($packingList) => $packingList->owner->company_module_id) + )); + } } diff --git a/resources/assets/vue/components/containers/forms/ContainerCommentFormComponent.vue b/resources/assets/vue/components/containers/forms/ContainerCommentFormComponent.vue index a77807fa..b38f7ebb 100644 --- a/resources/assets/vue/components/containers/forms/ContainerCommentFormComponent.vue +++ b/resources/assets/vue/components/containers/forms/ContainerCommentFormComponent.vue @@ -1,5 +1,5 @@