From 46a0e670bab6de7db1a391712222ee5ba9a2843b Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 4 May 2024 17:51:57 +0800 Subject: [PATCH 01/39] Fix emails cannot be sent with attachment --- app/Classes/Notifications/InvoiceIssuedEmail.php | 7 ++++++- app/Classes/Notifications/ShipmentDepartureEmail.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Classes/Notifications/InvoiceIssuedEmail.php b/app/Classes/Notifications/InvoiceIssuedEmail.php index 8a5c90cc..bbd4271d 100644 --- a/app/Classes/Notifications/InvoiceIssuedEmail.php +++ b/app/Classes/Notifications/InvoiceIssuedEmail.php @@ -8,6 +8,7 @@ use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\PackingList; use App\Models\User; use Illuminate\Notifications\Messages\MailMessage; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; class InvoiceIssuedEmail extends AbstractEmail @@ -35,10 +36,14 @@ class InvoiceIssuedEmail extends AbstractEmail $invoice = $this->packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::APPROVED)->first(); $invoiceDocument = $invoice->documents()->first()->files; + // $fileContent = Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file); + $filePath = storage_path('app/documents/' . $invoiceDocument->first()->file->file_info->original->file); + + Log::info('InvoiceIssuedEmail sent - Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference); return (new MailMessage) ->subject('Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference) - ->attach(Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file), [ + ->attach($filePath, [ 'as' => 'name.pdf', 'mime' => 'application/pdf', ])->view('emails.shipment.invoice', ['user' => $this->user, 'packingList' => $this->packingList]); diff --git a/app/Classes/Notifications/ShipmentDepartureEmail.php b/app/Classes/Notifications/ShipmentDepartureEmail.php index 44362d44..902ece25 100644 --- a/app/Classes/Notifications/ShipmentDepartureEmail.php +++ b/app/Classes/Notifications/ShipmentDepartureEmail.php @@ -9,6 +9,7 @@ use App\Models\PackingList; use App\Models\PasswordReset; use App\Models\User; use Illuminate\Notifications\Messages\MailMessage; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; class ShipmentDepartureEmail extends AbstractEmail @@ -40,10 +41,14 @@ class ShipmentDepartureEmail extends AbstractEmail $invoiceDocument = $invoice->documents()->first()->files; + // $fileContent = Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file); + $filePath= storage_path('app/documents/' . $invoiceDocument->first()->file->file_info->original->file); + + Log::info('ShipmentDepartureEmail sent - Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference); return (new MailMessage) ->subject('Your packages are on the way to malaysia - Invoice pending payment for order no.'. $this->packingList->owner->reference) - ->attach(Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file), [ + ->attach($filePath, [ 'as' => 'name.pdf', 'mime' => 'application/pdf', ])->bcc(['email_test@cief-malaysia.com'])->view('emails.shipment.ETD', ['user' => $this->user, 'packingList' => $this->packingList]); From 1705b5c2e5b92d13a60020e76051d66a6737427b Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 6 May 2024 13:19:23 +0800 Subject: [PATCH 02/39] Fix a front end UX problem reported by Yien --- .../CustomerPaymentsBillingComponent.vue | 21 ++++++++++++++----- .../forms/PaymentFormComponent.vue | 1 + .../PaymentVerificationFormComponent.vue | 9 ++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue index 244ba240..f93ba436 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue @@ -68,10 +68,10 @@ - MYR {{(Math.round((item.outstanding + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} -
+
Make Payment
@@ -238,6 +238,17 @@ latestComment() { let questions = this.item.remarks; return questions.slice().reverse()[0]; + }, + paymentPending(){ + if (Array.isArray(this.item.transactions)) { + for (let i = 0; i < this.item.transactions.length; i++) { + const status = this.item.transactions[i].status; + if (status === 1) { + return true; + } + } + } + return false; } }, created(){ diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue index bd861a20..3ff38d1f 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue @@ -157,6 +157,7 @@ this.error = response.payload.data.message; } else{ + this.closeModal(); this.updateList(); } } diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentVerificationFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentVerificationFormComponent.vue index bb1df036..a60f6b14 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/PaymentVerificationFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentVerificationFormComponent.vue @@ -76,9 +76,14 @@ files: this.files }; this.submit(this.route('api.transaction.payment.verification.create', this.data.id), 'post', this.section, true, true) - } + }, + successHandler(response){ + this.closeModal(); + this.formHandler(); + window.location.reload(); + }, }, mixins: [ModalFromHandler] } - \ No newline at end of file + From f361a7e185fc2c659f0e0f423d0c0d8b2b5b7183 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 8 May 2024 00:24:22 +0800 Subject: [PATCH 03/39] fix MappableTransactionWithDetailsResource.php --- app/Http/Resources/MappableTransactionWithDetailsResource.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/MappableTransactionWithDetailsResource.php b/app/Http/Resources/MappableTransactionWithDetailsResource.php index bf1fcf1d..1b287a75 100644 --- a/app/Http/Resources/MappableTransactionWithDetailsResource.php +++ b/app/Http/Resources/MappableTransactionWithDetailsResource.php @@ -32,7 +32,7 @@ class MappableTransactionWithDetailsResource extends JsonResource if ($this->type === TransactionType::PAYMENT) { $order = $this->owner->owner->owner; - $data['order_reference'] = $order->reference; + $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])) { @@ -52,7 +52,7 @@ class MappableTransactionWithDetailsResource extends JsonResource 'id' => $payment->id, 'updated_at' => $payment->updated_at, 'debtor_code' => $order->companyModule->company->debtor, - 'order_reference' => $order->reference, + 'order_reference' => $order->reference ?? '', 'bill_no' => null, 'type' => $payment->type, 'marking' => null, From b90dae882e3ced6243184aa38b5fcd15cdd062a0 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 8 May 2024 00:26:12 +0800 Subject: [PATCH 04/39] Fix a problem with inefficient query discovered from Laravel Vapor integration --- .../sections/AdminPaymentsBillingSectionComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue index 190ebe17..6ab087a5 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue @@ -113,7 +113,7 @@
- +
From 4a41c89024d1aaf0312bf87a3f83b9704ef4622b Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 8 May 2024 00:30:01 +0800 Subject: [PATCH 05/39] fix MappableTransactionWithDetailsResource.php --- ...MappableTransactionWithDetailsResource.php | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/app/Http/Resources/MappableTransactionWithDetailsResource.php b/app/Http/Resources/MappableTransactionWithDetailsResource.php index 1b287a75..c9f9bfad 100644 --- a/app/Http/Resources/MappableTransactionWithDetailsResource.php +++ b/app/Http/Resources/MappableTransactionWithDetailsResource.php @@ -32,9 +32,11 @@ class MappableTransactionWithDetailsResource extends JsonResource if ($this->type === TransactionType::PAYMENT) { $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 + if ($order) { + $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 : ''; @@ -48,17 +50,20 @@ class MappableTransactionWithDetailsResource extends JsonResource if ($payments->count()) { $data['payment_transactions'] = $payments->map(function ($payment) { $order = $payment->owner->owner->owner; - return [ - 'id' => $payment->id, - 'updated_at' => $payment->updated_at, - 'debtor_code' => $order->companyModule->company->debtor, - 'order_reference' => $order->reference ?? '', - 'bill_no' => null, - 'type' => $payment->type, - 'marking' => null, - 'amount' => $payment->amount, - 'created_at' => $this->created_at - ]; + + if ($order) { + return [ + 'id' => $payment->id, + 'updated_at' => $payment->updated_at, + 'debtor_code' => $order->companyModule->company->debtor, + 'order_reference' => $order->reference, + 'bill_no' => null, + 'type' => $payment->type, + 'marking' => null, + 'amount' => $payment->amount, + 'created_at' => $this->created_at + ]; + } })->toArray(); } else { $data['status'] = 'error'; From 5f24f584805f3f077d92c22df7bdd6eb6e52ac20 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 8 May 2024 00:48:15 +0800 Subject: [PATCH 06/39] Move a file that should no longer be used --- .../{ => deprecated}/SingleAdminPaymentsBillingComponent.vue | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename resources/assets/vue/components/paymentsBilling/elements/{ => deprecated}/SingleAdminPaymentsBillingComponent.vue (100%) diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/deprecated/SingleAdminPaymentsBillingComponent.vue similarity index 100% rename from resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingComponent.vue rename to resources/assets/vue/components/paymentsBilling/elements/deprecated/SingleAdminPaymentsBillingComponent.vue From 1ac4615c99421ef4779d24dc1b35b2fc09302752 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 8 May 2024 00:52:33 +0800 Subject: [PATCH 07/39] Delete a file that should no longer be used --- .../SingleAdminPaymentsBillingComponent.vue | 322 ------------------ 1 file changed, 322 deletions(-) delete mode 100644 resources/assets/vue/components/paymentsBilling/elements/deprecated/SingleAdminPaymentsBillingComponent.vue diff --git a/resources/assets/vue/components/paymentsBilling/elements/deprecated/SingleAdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/deprecated/SingleAdminPaymentsBillingComponent.vue deleted file mode 100644 index 825d9a67..00000000 --- a/resources/assets/vue/components/paymentsBilling/elements/deprecated/SingleAdminPaymentsBillingComponent.vue +++ /dev/null @@ -1,322 +0,0 @@ - - From b0fa73a12b3f2ad4888bde90d291f27f900eb34a Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 8 May 2024 01:52:51 +0800 Subject: [PATCH 08/39] Debugging --- ...heckStorageInvoiceTransactionProcessor.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php index dfe76267..82f4634d 100644 --- a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php @@ -177,11 +177,13 @@ class CheckStorageInvoiceTransactionProcessor $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'); + $dt2 = Carbon::now()->copy()->addDay()->startOfDay(); $interval = Carbon::parse($dt2)->diff($dt1); + Log::channel('storage_invoices')->info('dt1: '.json_encode($dt1)); + Log::channel('storage_invoices')->info('dt2: '.json_encode($dt2)); + Log::channel('storage_invoices')->info('interval: '.json_encode($interval)); + Log::channel('storage_invoices')->info('Carbon now: '.json_encode(Carbon::now())); + $resultNumberOfDaysExceeded = $interval->days - $resultNumberOfDaysFree; $storageInvoice = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->first(); @@ -200,14 +202,13 @@ class CheckStorageInvoiceTransactionProcessor $taxPercentage = TaxPercentage::DEFAULT; $price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded; $dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00')); - $shippingInvoiceTransactionCreatedDate = Carbon::now(); - Log::channel('storage_invoices')->info('storageInvoice: '.json_encode($storageInvoice).', $transaction->status: '.$transaction->status); + Log::channel('storage_invoices')->info('dateToCompare: '.json_encode($dateToCompare)); if(!$storageInvoice && $resultNumberOfDaysExceeded > 0 && $transaction->status != ApprovalStatus::COMPLETED){ Log::channel('storage_invoices')->info('Created $transaction->id: '.$transaction->id); $billNumber = $this->generatesTransactionBillNumber->execute('STOR-'); - if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare)) { + if (Carbon::now()->isAfter($dateToCompare)) { $taxPercentage = TaxPercentage::SIX_PERCENT; $total_tax = $price_cbm * $taxPercentage / 100; $price_cbm = $price_cbm + $total_tax; @@ -228,13 +229,13 @@ class CheckStorageInvoiceTransactionProcessor $paymentStorageTransaction = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::APPROVED)->first(); if($paymentStorageTransaction){ $dateStorageInvoicePaid = $paymentStorageTransaction->created_at->copy()->addDay()->startOfDay(); - Log::channel('storage_invoices')->info('dateStorageInvoicePaid: '.$dateStorageInvoicePaid.', resultCurrentDate: '.$resultCurrentDate); + Log::channel('storage_invoices')->info('dateStorageInvoicePaid: '.$dateStorageInvoicePaid.', resultCurrentDate: '.$dt2->format('Y-m-d H:i:s')); $intervalRecalculate = Carbon::parse($dateStorageInvoicePaid)->diff($dt1); $resultNumberOfDaysExceeded = $intervalRecalculate->days - $resultNumberOfDaysFree; $price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded; } - if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare)) { + if (Carbon::now()->isAfter($dateToCompare)) { $taxPercentage = TaxPercentage::SIX_PERCENT; $total_tax = $price_cbm * $taxPercentage / 100; $price_cbm = $price_cbm + $total_tax; @@ -280,8 +281,8 @@ class CheckStorageInvoiceTransactionProcessor 'storageInvoiceId' => $storageInvoiceId, 'numberOfDaysExceeded' => $resultNumberOfDaysExceeded, 'numberOfDaysFree' => $resultNumberOfDaysFree, - 'startDate' => $resultStartDate, - 'currentDate' => $resultCurrentDate, + 'startDate' => $dt1->format('Y-m-d'), + 'currentDate' => $dt2->format('Y-m-d H:i:s'), 'cbm' => $cbm, 'pricePerCBM' => $pricePerCBM, 'storageInvoice' => new TransactionWithStorageResource($storageInvoice) From 06e3049e507c1226693b04a2b29715b9974900c0 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 8 May 2024 03:03:58 +0800 Subject: [PATCH 09/39] Debugging --- .../Processors/CheckStorageInvoiceTransactionProcessor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php index 82f4634d..0241961b 100644 --- a/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CheckStorageInvoiceTransactionProcessor.php @@ -164,6 +164,7 @@ class CheckStorageInvoiceTransactionProcessor if ($transport) { $schedule = $transport->schedules->last(); if ($schedule) { + Log::channel('storage_invoices')->info('schedule: '.json_encode($schedule)); return $schedule->eta; } } @@ -179,6 +180,7 @@ class CheckStorageInvoiceTransactionProcessor $dt1 = $eta->copy()->addDay()->startOfDay(); $dt2 = Carbon::now()->copy()->addDay()->startOfDay(); $interval = Carbon::parse($dt2)->diff($dt1); + Log::channel('storage_invoices')->info('eta: '.json_encode($eta)); Log::channel('storage_invoices')->info('dt1: '.json_encode($dt1)); Log::channel('storage_invoices')->info('dt2: '.json_encode($dt2)); Log::channel('storage_invoices')->info('interval: '.json_encode($interval)); From 2d92b1a8ab1ba419af9466abc1315aedab02256c Mon Sep 17 00:00:00 2001 From: jiasheng224 Date: Wed, 8 May 2024 18:30:12 +0800 Subject: [PATCH 10/39] fulfilment banner module --- ...panyConnectionToConnectionSegmentLogic.php | 14 ++- .../FulfilmentConfirmationFormComponent.vue | 38 ++++++++ .../elements/FulfilmentLaterFormComponent.vue | 78 +++++++++++++++ .../NewServiceAnnouncementComponent.vue | 94 +++++++++++++++++++ resources/views/partials/menu.blade.php | 7 +- 5 files changed, 228 insertions(+), 3 deletions(-) create mode 100644 resources/assets/vue/components/companies/elements/FulfilmentConfirmationFormComponent.vue create mode 100644 resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue create mode 100644 resources/assets/vue/components/companies/elements/NewServiceAnnouncementComponent.vue diff --git a/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php b/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php index cee72e84..e832b854 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php @@ -7,6 +7,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor; use App\Classes\Modules\Companies\Services\FetchesCompany; use App\Classes\Modules\Companies\Services\FetchesCompanyConnection; +use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject; +use App\Classes\Modules\Contacts\Processors\CreateContactProcessor; use App\Http\Resources\CompanyResource; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -33,17 +35,22 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController /** @var AssignConnectionSegmentProcessor */ private $assignCompanyConnectionToConnectionSegmentProcessor; + /** @var CreateContactProcessor */ + private $createContactProcessor; + /** * AssignCompanyToSegmentLogic constructor. * @param FetchesCompany $fetchesCompany * @param FetchesCompanyConnection $fetchesCompanyConnection * @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor + * @param CreateContactProcessor $createContactProcessor */ - public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor) + public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor, CreateContactProcessor $createContactProcessor) { $this->fetchesCompany = $fetchesCompany; $this->fetchesCompanyConnection = $fetchesCompanyConnection; $this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor; + $this->createContactProcessor = $createContactProcessor; } /** @@ -62,6 +69,11 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController $this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id')); + if ($request->input('segment_id') == 11) { + $contactObject = new ContactObject('Whatsapp: ' . $request->input('name'), $request->input('phone'), null, null); + $this->createContactProcessor->execute($contactObject, $company); + } + return $this->resourceResponse(new CompanyResource($company)); } } \ No newline at end of file diff --git a/resources/assets/vue/components/companies/elements/FulfilmentConfirmationFormComponent.vue b/resources/assets/vue/components/companies/elements/FulfilmentConfirmationFormComponent.vue new file mode 100644 index 00000000..70222929 --- /dev/null +++ b/resources/assets/vue/components/companies/elements/FulfilmentConfirmationFormComponent.vue @@ -0,0 +1,38 @@ + + diff --git a/resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue b/resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue new file mode 100644 index 00000000..2d803989 --- /dev/null +++ b/resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue @@ -0,0 +1,78 @@ + + diff --git a/resources/assets/vue/components/companies/elements/NewServiceAnnouncementComponent.vue b/resources/assets/vue/components/companies/elements/NewServiceAnnouncementComponent.vue new file mode 100644 index 00000000..8e908ebf --- /dev/null +++ b/resources/assets/vue/components/companies/elements/NewServiceAnnouncementComponent.vue @@ -0,0 +1,94 @@ + + + diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index f019d874..d19bbe2a 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -206,8 +206,8 @@
-
-
+
+
@@ -223,6 +223,9 @@
+
+ +
From bd42f7213aa00cee08ae4a6326978074628e2655 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 18 May 2024 18:55:21 +0800 Subject: [PATCH 11/39] Vue Polling - Refactor code to use vuex --- .../general/elements/ListPollingComponent.vue | 98 +++---------- .../assets/vue/vuex/modules/jobPolling.js | 135 ++++++++++++++++++ resources/assets/vue/vuex/store.js | 4 +- 3 files changed, 161 insertions(+), 76 deletions(-) create mode 100644 resources/assets/vue/vuex/modules/jobPolling.js diff --git a/resources/assets/vue/components/general/elements/ListPollingComponent.vue b/resources/assets/vue/components/general/elements/ListPollingComponent.vue index 03c58088..d7bdfcd4 100644 --- a/resources/assets/vue/components/general/elements/ListPollingComponent.vue +++ b/resources/assets/vue/components/general/elements/ListPollingComponent.vue @@ -49,7 +49,7 @@ - diff --git a/resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue b/resources/assets/vue/components/companies/elements/FulfilmentInterestedFormComponent.vue similarity index 57% rename from resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue rename to resources/assets/vue/components/companies/elements/FulfilmentInterestedFormComponent.vue index 2d803989..28492048 100644 --- a/resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue +++ b/resources/assets/vue/components/companies/elements/FulfilmentInterestedFormComponent.vue @@ -1,6 +1,6 @@ From e2dc83e441360645c3b081ca0080cd791543fd17 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 21 May 2024 01:26:09 +0800 Subject: [PATCH 17/39] add segments in the menu bar. --- resources/views/pages/segments/index.blade.php | 11 +++-------- resources/views/partials/menu.blade.php | 11 +++++++++++ routes/web.php | 8 +------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/resources/views/pages/segments/index.blade.php b/resources/views/pages/segments/index.blade.php index 2ef30a33..61699bba 100644 --- a/resources/views/pages/segments/index.blade.php +++ b/resources/views/pages/segments/index.blade.php @@ -1,14 +1,9 @@ @extends('layouts.base_portal') @section('inner_content') -@php - if($segment){ - $active = 0; - } -@endphp -
-
+
+
-
+
diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index d19bbe2a..2e254332 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -180,6 +180,17 @@
Support
+
+
+ +
+
+
Segments
+
+
diff --git a/routes/web.php b/routes/web.php index 11dc5450..bc073633 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1313,11 +1313,5 @@ Route::get('/show-all-extra-payments', function () { }); Route::get('/segments', function (Request $request) { - $segment = null; - - if ($request->has('id')) { - $segment = App\Models\Segment::find($request->id); - } - - return view('pages.segments.index', compact('segment')); + return view('pages.segments.index'); })->name('segments'); From c9ac435e37ac5432da74fc639fc61789f946dd77 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 21 May 2024 01:33:24 +0800 Subject: [PATCH 18/39] update confirmation message --- .../elements/NewServiceAnnouncementComponent.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/assets/vue/components/companies/elements/NewServiceAnnouncementComponent.vue b/resources/assets/vue/components/companies/elements/NewServiceAnnouncementComponent.vue index cab754d0..9f69a28e 100644 --- a/resources/assets/vue/components/companies/elements/NewServiceAnnouncementComponent.vue +++ b/resources/assets/vue/components/companies/elements/NewServiceAnnouncementComponent.vue @@ -51,16 +51,16 @@
-
Not Interested
-
Are you sure you are not interested?
+
Are you Sure?
+
Are you sure you are not interested in this service?
-
Cancel
+
No, take me back
-
Confirm
+
Yes, I’m sure
From 141dab15b65038ae2b08014cef611e08816d9ad3 Mon Sep 17 00:00:00 2001 From: Jia Sheng Date: Thu, 23 May 2024 11:44:18 +0800 Subject: [PATCH 19/39] fix segment requried contact bug --- .../AssignCompanyConnectionToConnectionSegmentLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php b/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php index 614e882d..8069663c 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php @@ -69,7 +69,7 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController $this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id')); - if ($request->input('segment_id') != 12) { + if ($request->input('segment_id') == 10 || $request->input('segment_id') == 11) { $contactObject = new ContactObject('Whatsapp: ' . $request->input('name'), $request->input('phone'), null, null); $this->createContactProcessor->execute($contactObject, $company); } From b0eca183434a1ae6337437fce7b579ce746de817 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Mon, 27 May 2024 00:53:48 +0800 Subject: [PATCH 20/39] show packinglist reference for admin only --- app/Http/Resources/TransactionWithStorageResource.php | 6 ++++++ .../elements/CustomerPaymentsBillingComponent.vue | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/Http/Resources/TransactionWithStorageResource.php b/app/Http/Resources/TransactionWithStorageResource.php index dd307ad8..3831ba37 100644 --- a/app/Http/Resources/TransactionWithStorageResource.php +++ b/app/Http/Resources/TransactionWithStorageResource.php @@ -5,6 +5,7 @@ namespace App\Http\Resources; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\Group; +use App\Models\PackingList; use App\Models\Transaction; use App\Models\Wallet; use Carbon\Carbon; @@ -54,6 +55,10 @@ class TransactionWithStorageResource extends JsonResource } + $packingListReference = null; + if ($this->owner instanceof PackingList) { + $packingListReference = $this->owner->reference; + } $ts = $this->groups->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION])->last(); if ($ts) { @@ -119,6 +124,7 @@ class TransactionWithStorageResource extends JsonResource ->get() ), 'remarks' => RemarkResource::collection($this->remarks), + 'packing_list_reference' => $packingListReference, '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:i:s A'), diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue index f93ba436..fcd25eb0 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue @@ -93,6 +93,16 @@
+
+
+
+
+

Packinglist Reference

+
{{ item.packing_list_reference }}
+
+
+
+
From 30edc3eaba2100267dd9fb30c44c3f920d16e344 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 30 May 2024 23:08:05 +0800 Subject: [PATCH 21/39] updates RescheduleContainerLogic delete all the previous container transport schedule, then create a new one --- .../Containers/RescheduleContainerLogic.php | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/RescheduleContainerLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/RescheduleContainerLogic.php index b3638b90..268055de 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/RescheduleContainerLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/RescheduleContainerLogic.php @@ -56,27 +56,21 @@ class RescheduleContainerLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - try { - $container = $this->fetchesContainer->execute(['id' => $request->route('id')]); - $transport = $container->transports()->first(); + $container = $this->fetchesContainer->execute(['id' => $request->route('id')]); + $transport = $container->transports()->first(); - $old_sechedule = $transport->schedules()->first(); + $old_schedule = $transport->schedules()->delete(); - $this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED); + // $this->updatesScheduleStatus->execute($old_schedule, ApprovalStatus::REJECTED); - $scheduleObject = new ScheduleObject( - Carbon::parse($request->input('etd')), - Carbon::parse($request->input('eta')), - ApprovalStatus::APPROVED - ); - $schedule = $this->createsSchedule->execute($transport, $scheduleObject); - - return $this->resourceResponse(new ContainerResource($container)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + $scheduleObject = new ScheduleObject( + Carbon::parse($request->input('etd')), + Carbon::parse($request->input('eta')), + ApprovalStatus::APPROVED + ); + $schedule = $this->createsSchedule->execute($transport, $scheduleObject); + return $this->resourceResponse(new ContainerResource($container)); } } From a392b8a5eb129be39dea41cce368ffa367daa0c6 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 7 Jun 2024 17:35:57 +0800 Subject: [PATCH 22/39] test ga4 --- resources/views/layouts/base.blade.php | 14 ++++++++++---- resources/views/vendor/head.blade.php | 8 -------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index 40e53d6c..b4ae7d76 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -4,10 +4,16 @@ @include('vendor/head') - - - + + + +
@yield('content')
diff --git a/resources/views/vendor/head.blade.php b/resources/views/vendor/head.blade.php index f36a5b76..dd87bbda 100644 --- a/resources/views/vendor/head.blade.php +++ b/resources/views/vendor/head.blade.php @@ -1,11 +1,3 @@ - - - - @yield('title', 'IZYIM Shipping') From 1e9af59b91fe2c04595ad9a002851ede9fe622f3 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 7 Jun 2024 17:40:48 +0800 Subject: [PATCH 23/39] test gtag --- resources/views/layouts/base.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index b4ae7d76..166d0a64 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -5,13 +5,13 @@ - +
From b000c25e668c1afe9a368ceac532c67cb3183362 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 9 Jun 2024 12:00:19 +0800 Subject: [PATCH 24/39] 'Your Payment Proof' feature missing for order with storage invoices through group payment --- .../TransactionWithStorageResource.php | 34 ++++++++++++++----- .../elements/PaymentHistoryComponent.vue | 17 ++++++++-- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/app/Http/Resources/TransactionWithStorageResource.php b/app/Http/Resources/TransactionWithStorageResource.php index 3831ba37..66ea152c 100644 --- a/app/Http/Resources/TransactionWithStorageResource.php +++ b/app/Http/Resources/TransactionWithStorageResource.php @@ -28,7 +28,9 @@ class TransactionWithStorageResource extends JsonResource $groupPaymentAttemptsFiltered = []; $group_payment_expired = null; $group_payment_history = null; + $group_payment_history_query = null; $groupTotalAmount = 0; + $payment_history = null; if ($this->owner instanceof Transaction) { if ($this->owner) { @@ -44,7 +46,8 @@ class TransactionWithStorageResource extends JsonResource if($this->groups){ $group_payment_attempts = GroupForOrderV2Resource::collection($this->groups->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])); $group_payment_expired = GroupForOrderV2Resource::collection($this->groupsWithTrashed->whereIn('status', [ApprovalStatus::EXPIRED])); - $group_payment_history = GroupForOrderV2Resource::collection($this->groups->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED])); + $group_payment_history_query = $this->groups->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED]); + $group_payment_history = GroupForOrderV2Resource::collection($group_payment_history_query); } } else { @@ -61,7 +64,7 @@ class TransactionWithStorageResource extends JsonResource } $ts = $this->groups->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION])->last(); - if ($ts) { + if ($ts && $group_payment_history && $group_payment_attempts) { $paymentTransaction = Transaction::where('payment_reference', $ts->reference)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION])->first(); if($paymentTransaction){ $groupTotalAmount = (double) $this->amount; @@ -81,6 +84,18 @@ class TransactionWithStorageResource extends JsonResource } + $payment_history = TransactionResource::collection($this->transactions() + ->payments() + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]) + ->get()); + + //For 'Your Payment Proof' at frontend + if($group_payment_history_query){ + foreach ($payment_history as $item) { + $item['payment_reference'] = $this->getReferenceForGroupPayment($group_payment_history_query); + } + } + return [ 'id' => $this->id, 'owner_type' => $this->owner_type, @@ -117,12 +132,7 @@ class TransactionWithStorageResource extends JsonResource ->payments()->where('status', ApprovalStatus::EXPIRED) ->get() ), - 'payment_history' => TransactionResource::collection( - $this->transactions() - ->payments() - ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]) - ->get() - ), + 'payment_history' => $payment_history, 'remarks' => RemarkResource::collection($this->remarks), 'packing_list_reference' => $packingListReference, 'storages' => $this->storages ? $this->storages : null, //from middleware @@ -132,4 +142,12 @@ class TransactionWithStorageResource extends JsonResource 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y') ]; } + + private function getReferenceForGroupPayment($groups){ + if(count($groups)){ + $firstGroup = $groups[0]; + return $firstGroup['reference']; + } + return null; + } } diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue index 8d5dee0f..94f23bc5 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue @@ -157,6 +157,13 @@
+
@@ -181,9 +188,13 @@ }, methods: { clickExpand(){ - if(this.item - && ((this.item.payment_method !== 5 && this. item.documents.length) - || (this.item.payment_method === 5 && (this.item.status === 2 || this.item.status === 3)))){ + // if(this.item + // && ((this.item.payment_method !== 5 && this. item.documents.length) + // || (this.item.payment_method === 5 && (this.item.status === 2 || this.item.status === 3)))){ + // this.expandPaymentDetails = !this.expandPaymentDetails; + // } + + if(this.item){ this.expandPaymentDetails = !this.expandPaymentDetails; } }, From aeaec32dcbdac72eb8f7db1d90f0e383d18717f9 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 9 Jun 2024 12:16:18 +0800 Subject: [PATCH 25/39] 'Your Payment Proof' feature missing for order with storage invoices through group payment --- app/Http/Resources/TransactionWithStorageResource.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Resources/TransactionWithStorageResource.php b/app/Http/Resources/TransactionWithStorageResource.php index 66ea152c..42f42cc0 100644 --- a/app/Http/Resources/TransactionWithStorageResource.php +++ b/app/Http/Resources/TransactionWithStorageResource.php @@ -90,7 +90,8 @@ class TransactionWithStorageResource extends JsonResource ->get()); //For 'Your Payment Proof' at frontend - if($group_payment_history_query){ + + if($group_payment_history_query && count($group_payment_history_query) > 0){ foreach ($payment_history as $item) { $item['payment_reference'] = $this->getReferenceForGroupPayment($group_payment_history_query); } From e63e3e707f2f05c036fbf5bd8a4273fd45b99f97 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 9 Jun 2024 12:44:19 +0800 Subject: [PATCH 26/39] 'Your Payment Proof' feature missing for order with storage invoices through group payment --- app/Http/Resources/TransactionWithStorageResource.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/TransactionWithStorageResource.php b/app/Http/Resources/TransactionWithStorageResource.php index 42f42cc0..52f35fdf 100644 --- a/app/Http/Resources/TransactionWithStorageResource.php +++ b/app/Http/Resources/TransactionWithStorageResource.php @@ -92,8 +92,10 @@ class TransactionWithStorageResource extends JsonResource //For 'Your Payment Proof' at frontend if($group_payment_history_query && count($group_payment_history_query) > 0){ - foreach ($payment_history as $item) { - $item['payment_reference'] = $this->getReferenceForGroupPayment($group_payment_history_query); + if($this->getReferenceForGroupPayment($group_payment_history_query)){ + foreach ($payment_history as $item) { + $item['payment_reference'] = $this->getReferenceForGroupPayment($group_payment_history_query); + } } } From 1be405ca93a9d9542b30ca7d55dd9d75b6fca6fd Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 13 Jun 2024 23:47:43 +0800 Subject: [PATCH 27/39] fix error message in admin dashbaord --- .../elements/UnclaimedPackinglistComponent.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue b/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue index b4b928c3..71bd5d72 100644 --- a/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue +++ b/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue @@ -17,7 +17,7 @@
- +
@@ -51,7 +51,7 @@
Cancel
-
Confirm
+
Confirm
@@ -78,6 +78,12 @@ From ea920717a18008d5bd18733d5dd409ef6e991dc7 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 15 Jun 2024 05:56:23 +0800 Subject: [PATCH 28/39] Fix a rounding problem in group payment which will result in goods cannot be released through CallbackBillplzLogic --- .../elements/CustomerPaymentBillingInnerComponent.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/companies/elements/CustomerPaymentBillingInnerComponent.vue b/resources/assets/vue/components/companies/elements/CustomerPaymentBillingInnerComponent.vue index 19ca390a..634550da 100644 --- a/resources/assets/vue/components/companies/elements/CustomerPaymentBillingInnerComponent.vue +++ b/resources/assets/vue/components/companies/elements/CustomerPaymentBillingInnerComponent.vue @@ -116,9 +116,10 @@ }, sumAmount () { var new_object = this.selectedInvoice; - return Object.keys(new_object).reduce(function(total, key) { - return total + Math.round(new_object[key].amount * 100) / 100; + var total = Object.keys(new_object).reduce(function(total, key) { + return total + new_object[key].amount; }, 0).toFixed(2); + return Math.round(total * 100) / 100; }, selectedIds () { return this.selectedInvoice.map(s=>s.id); From 713922d2ee55c7df3b552e48af445df45211ecaa Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 16 Jun 2024 14:04:16 +0800 Subject: [PATCH 29/39] Data patch meant to fix a group payment with group id 609 and transaction id 16803 that got stuck after making paying --- .../Processors/CallbackBillplzProcessor.php | 24 ++- ...ePaymentTransactionOneTimeFixProcessor.php | 188 ++++++++++++++++++ ...imeTransactionFixBillplzFailedCallback.php | 11 +- 3 files changed, 215 insertions(+), 8 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Processors/CreatePaymentTransactionOneTimeFixProcessor.php diff --git a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php index b5909cf1..aca0da1c 100644 --- a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php +++ b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php @@ -8,6 +8,7 @@ use App\Models\Group; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor; +use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionOneTimeFixProcessor; use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance; @@ -32,6 +33,9 @@ class CallbackBillplzProcessor /** @var CreatePaymentTransactionProcessor */ private $createPaymentTransactionProcessor; + /** @var CreatePaymentTransactionOneTimeFixProcessor */ + private $createPaymentTransactionOneTimeFixProcessor; + /** @var ReleaseGoodsToCustomerProcessor */ private $releaseGoodsToCustomerProcessor; @@ -44,7 +48,7 @@ class CallbackBillplzProcessor * @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor * @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor */ - public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor) + public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor, CreatePaymentTransactionOneTimeFixProcessor $createPaymentTransactionOneTimeFixProcessor) { $this->updatesTransactionStatus = $updatesTransactionStatus; $this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor; @@ -52,6 +56,7 @@ class CallbackBillplzProcessor $this->updatesWalletBalance = $updatesWalletBalance; $this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor; $this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor; + $this->createPaymentTransactionOneTimeFixProcessor = $createPaymentTransactionOneTimeFixProcessor; } @@ -81,8 +86,16 @@ class CallbackBillplzProcessor foreach ($group->groupTransactions as $groupTransaction) { $invoice = $groupTransaction->transaction; if($invoice->status !== ApprovalStatus::COMPLETED){ - $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false); - + if($group->id === 609){ + Log::info(json_encode($group->id)); + $paymentTransaction = $this->createPaymentTransactionOneTimeFixProcessor->execute($invoice, PaymentMethodType::WALLET, null, $transaction->created_at, false); + $paymentTransaction->created_at = $transaction->created_at; + $paymentTransaction->updated_at = $transaction->created_at; + $paymentTransaction->save(); + } + else{ + $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false); + } if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ $pL = $invoice->owner; $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); @@ -123,6 +136,11 @@ class CallbackBillplzProcessor else{ Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed + + if($transaction->id === 16803){ + Log::channel('storage_invoices')->info('One time data patch for transaction: '.$transaction->id); + return true; + } return false; } } diff --git a/app/Classes/Modules/Transactions/Processors/CreatePaymentTransactionOneTimeFixProcessor.php b/app/Classes/Modules/Transactions/Processors/CreatePaymentTransactionOneTimeFixProcessor.php new file mode 100644 index 00000000..3d648e76 --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/CreatePaymentTransactionOneTimeFixProcessor.php @@ -0,0 +1,188 @@ +generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->createsPaymentTransaction = $createsPaymentTransaction; + $this->createsBillplzBill = $createsBillplzBill; + $this->createsTransactionableTransaction = $createsTransactionableTransaction; + $this->updatesWalletBalance = $updatesWalletBalance; + $this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor; + $this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor; + $this->updatesTransactionStatus = $updatesTransactionStatus; + } + + /** + * @throws MalformedRequestException + */ + public function execute(Transaction $invoice, $payment_method, $bank_code, $date, $run = true) + { + $amount = $invoice->amount; + Log::info($invoice->owner); + $company_module = $invoice->owner->owner->companyModule()->first(); + $approvalStatus = ApprovalStatus::PENDING_SUBMISSION; + $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); + $payment_reference = null; + + if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) { + + // create billplz transaction + $payment_method = PaymentMethodType::PAYMENT_GATEWAY; + $billPlzBill = $this->createsBillplzBill->execute( + $company_module->name, + (app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com', + 'This payment is for the invoice number . ' . $billNumber, + $amount, + $billNumber, + $bank_code, + true + ); + + $payment_reference = $billPlzBill->id; + } + else if ($payment_method === PaymentMethodType::WALLET) { + /** @var Wallet $wallet */ + $wallet = $company_module->wallets()->first(); + + + // if((float) number_format(($wallet->amount - $amount),2) < 0){ + // throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.'); + // } + + $walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); + + $transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], ''); + $transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object); + $transaction->created_at = $date; + $transaction->updated_at = $date; + $transaction->save(); + + $payment_reference = $walletPaymentBillNumber; + + $this->updatesWalletBalance->execute($wallet, ($amount * -1)); + + 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); + } + } + + // later use this variabke to create a approved payment transaction + $approvalStatus = ApprovalStatus::APPROVED; + + // update invoice to completed + if($run){ + $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED); + } + } + else { + $payment_method = PaymentMethodType::CASH; + } + + $object = new TransactionObject( + $billNumber, + TransactionType::PAYMENT, + $company_module->id, + 1, + 1, + $payment_method, + $amount, + $amount, + 1, + 1, + 0, + 0, + 0, + null, + $approvalStatus, + null, + $payment_reference + ); + + $payment_transaction = $this->createsPaymentTransaction->execute($invoice, $object); + + return $payment_transaction; + } +} diff --git a/app/Console/Commands/OneTimeTransactionFixBillplzFailedCallback.php b/app/Console/Commands/OneTimeTransactionFixBillplzFailedCallback.php index f015e41b..9d4c648d 100644 --- a/app/Console/Commands/OneTimeTransactionFixBillplzFailedCallback.php +++ b/app/Console/Commands/OneTimeTransactionFixBillplzFailedCallback.php @@ -55,11 +55,12 @@ class OneTimeTransactionFixBillplzFailedCallback extends Command $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.'); + //Transaction fix with this one time fix command: 15205, 16803 + //This transaction, 16803 has approve payment but not its owner, shipping invoice + $transaction = Transaction::whereIn('id', [16803])->first(); + $this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 16803 cron started.'); - if($transaction && $transaction->id == 15205){ + if($transaction && $transaction->id == 16803){ $status = ApprovalStatus::APPROVED; $this->callbackBillplzProcessor->execute($transaction, $status); @@ -68,6 +69,6 @@ class OneTimeTransactionFixBillplzFailedCallback extends Command $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); + $this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 16803 cron ended. ElapsedTime: ' . $elapsedTime); } } From 2d98757c1cb11a9dd0429b3570f25381d8e33f56 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 16 Jun 2024 14:13:09 +0800 Subject: [PATCH 30/39] Data patch meant to fix a group payment with group id 609 and transaction id 16803 that got stuck after making paying --- .../Processors/CallbackBillplzProcessor.php | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php index aca0da1c..b5909cf1 100644 --- a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php +++ b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzProcessor.php @@ -8,7 +8,6 @@ use App\Models\Group; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor; -use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionOneTimeFixProcessor; use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance; @@ -33,9 +32,6 @@ class CallbackBillplzProcessor /** @var CreatePaymentTransactionProcessor */ private $createPaymentTransactionProcessor; - /** @var CreatePaymentTransactionOneTimeFixProcessor */ - private $createPaymentTransactionOneTimeFixProcessor; - /** @var ReleaseGoodsToCustomerProcessor */ private $releaseGoodsToCustomerProcessor; @@ -48,7 +44,7 @@ class CallbackBillplzProcessor * @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor * @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor */ - public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor, CreatePaymentTransactionOneTimeFixProcessor $createPaymentTransactionOneTimeFixProcessor) + public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor) { $this->updatesTransactionStatus = $updatesTransactionStatus; $this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor; @@ -56,7 +52,6 @@ class CallbackBillplzProcessor $this->updatesWalletBalance = $updatesWalletBalance; $this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor; $this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor; - $this->createPaymentTransactionOneTimeFixProcessor = $createPaymentTransactionOneTimeFixProcessor; } @@ -86,16 +81,8 @@ class CallbackBillplzProcessor foreach ($group->groupTransactions as $groupTransaction) { $invoice = $groupTransaction->transaction; if($invoice->status !== ApprovalStatus::COMPLETED){ - if($group->id === 609){ - Log::info(json_encode($group->id)); - $paymentTransaction = $this->createPaymentTransactionOneTimeFixProcessor->execute($invoice, PaymentMethodType::WALLET, null, $transaction->created_at, false); - $paymentTransaction->created_at = $transaction->created_at; - $paymentTransaction->updated_at = $transaction->created_at; - $paymentTransaction->save(); - } - else{ - $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false); - } + $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false); + if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){ $pL = $invoice->owner; $this->releaseGoodsToCustomerProcessor->execute($pL, $invoice); @@ -136,11 +123,6 @@ class CallbackBillplzProcessor else{ Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed - - if($transaction->id === 16803){ - Log::channel('storage_invoices')->info('One time data patch for transaction: '.$transaction->id); - return true; - } return false; } } From b593605c72234c3fd4a9afd507debd90695eec72 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 17 Jun 2024 08:51:09 +0800 Subject: [PATCH 31/39] A minor fix to not allow non-admin user to see admin data by navigating to the url /payment-and-billing-2 --- resources/views/pages/paymentAndBilling2.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/pages/paymentAndBilling2.blade.php b/resources/views/pages/paymentAndBilling2.blade.php index ac1de6b2..184b201e 100644 --- a/resources/views/pages/paymentAndBilling2.blade.php +++ b/resources/views/pages/paymentAndBilling2.blade.php @@ -131,7 +131,7 @@ -
+
From a36c5c3063271ed0348ce67daa3b96b3d15c3413 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 26 Jun 2024 12:47:44 +0800 Subject: [PATCH 32/39] show group-transaction-with-completed-payments --- app/Models/Group.php | 8 ++++++++ routes/web.php | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/Models/Group.php b/app/Models/Group.php index 276b0aa5..188b0fe5 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -84,4 +84,12 @@ class Group extends Model implements Documentable, Transactionable { return $this->BelongsTo(Currency::class, 'original_currency_id', 'id'); } + + /** + * @return hasOne + */ + public function payment() + { + return $this->hasOne(Transaction::class, 'payment_reference', 'reference'); + } } diff --git a/routes/web.php b/routes/web.php index bc073633..f2d6fc41 100644 --- a/routes/web.php +++ b/routes/web.php @@ -34,6 +34,7 @@ use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Crypt; use App\Models\Container; +use App\Models\Group; use App\Models\Transaction; use App\Models\Wallet; use Illuminate\Support\Facades\DB; @@ -1315,3 +1316,14 @@ Route::get('/show-all-extra-payments', function () { Route::get('/segments', function (Request $request) { return view('pages.segments.index'); })->name('segments'); + +Route::get('/group-transaction-with-completed-payments', function () { + $groups = Group::whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereHas('payment', function ($query) { + $query->whereIn('status', [2, 3]); + })->get(); + + foreach ($groups as $group) { + dump($group->groupTransactions->first()->transaction->owner->owner->reference); + } +}); From d7625aece7a627c26e9ac6df23844f27be070fa0 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 26 Jun 2024 13:07:30 +0800 Subject: [PATCH 33/39] update group-transaction-with-completed-payments --- routes/web.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index f2d6fc41..7e7c14f1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1324,6 +1324,20 @@ Route::get('/group-transaction-with-completed-payments', function () { })->get(); foreach ($groups as $group) { - dump($group->groupTransactions->first()->transaction->owner->owner->reference); + $groupPayment = $group->payment; + $order = $group->groupTransactions->first()->transaction->owner->owner; + $companyModule = $order->companyModule; + + $connection = $companyModule->connections()->first(); + $companyMarking = $connection ? $connection->invitee_reference : ''; + + dump([ + 'reference' => $group->reference, + 'groupPayment_id' => $groupPayment->id, + 'groupPayment_status' => $groupPayment->status, + 'order' => $order->reference, + 'companyMarking' => $companyMarking, + ]); + echo '' . $companyMarking . '
'; } }); From 669cac9bd41c4c2f861d0792ec55820d7009ac13 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 26 Jun 2024 13:47:58 +0800 Subject: [PATCH 34/39] fix-approved-payment-failed-group --- .../FixApprovedPaymentFailedGroup.php | 94 +++++++++++++++++++ .../elements/PaymentHistoryComponent.vue | 27 ++++++ 2 files changed, 121 insertions(+) create mode 100644 app/Console/Commands/FixApprovedPaymentFailedGroup.php diff --git a/app/Console/Commands/FixApprovedPaymentFailedGroup.php b/app/Console/Commands/FixApprovedPaymentFailedGroup.php new file mode 100644 index 00000000..97dfac24 --- /dev/null +++ b/app/Console/Commands/FixApprovedPaymentFailedGroup.php @@ -0,0 +1,94 @@ +callbackBillplzProcessor = $callbackBillplzProcessor; + } + + /** + * Execute the console command. + * + * @return int + */ + public function handle() + { + ini_set('memory_limit', '-1'); + + $this->outputArray = []; + $start = new Carbon(); + + $groups = Group::whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereHas('payment', function ($query) { + $query->whereIn('status', [2, 3]); + })->get(); + + foreach ($groups as $group) { + $transaction = $group->payment; + + $response = Http::withBasicAuth(config('billplz.api_key') . ':', '')->get(config('billplz.base_url') . '/api/v3/bills/' . $transaction->payment_reference); + + dump($transaction->payment_reference); + + if ($response->successful()) { + $data = $response->json(); + if ($data['paid']) { + $status = ApprovalStatus::PENDING_VERIFICATION; + + if ($data['state'] === 'paid') { + $status = ApprovalStatus::APPROVED; + } + + $this->info(Carbon::now() . ' : Fixing ' . $transaction->payment_reference); + $this->callbackBillplzProcessor->execute($transaction, $status); + } + } else { + $this->info("billplz error
"); + } + } + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + + if ($groups) { + $this->info(Carbon::now() . ' : Done . ElapsedTime: ' . $elapsedTime); + } + } +} diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue index 94f23bc5..e7a08882 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue @@ -92,6 +92,22 @@
+
+
+
Payment Method
+
+ {{ convertPaymentMethodToText(item.payment_method) }} +
+
+
+
Created At
+
{{ item.created_at }}
+
+
+
Updated At
+
{{ item.updated_at }}
+
+