From c44017486cb0ce9afd58a11d1288b9e10bd8e191 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 15 Oct 2024 14:55:11 +0800 Subject: [PATCH 01/19] Laravel Vapor - Fix a 504 error at /bookings/urgent page --- .../ListUrgentTransactionsLogic.php | 49 +++++++++++++ .../ListUrgentTransactionsController.php | 21 ++++++ .../Resources/TransactionUrgentResource.php | 71 +++++++++++++++++++ .../sections/UrgentListSectionComponent.vue | 4 +- routes/transaction.php | 1 + 5 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/ListUrgentTransactionsLogic.php create mode 100644 app/Http/Controllers/Transactions/ListUrgentTransactionsController.php create mode 100644 app/Http/Resources/TransactionUrgentResource.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListUrgentTransactionsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListUrgentTransactionsLogic.php new file mode 100644 index 00000000..35a57e48 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/ListUrgentTransactionsLogic.php @@ -0,0 +1,49 @@ +listsTransactions = $listsTransactions; + } + + /** + * @return array + */ + protected function notification():array { + return [ + 'title' => 'Retrieved Transactions Urgent', + 'message' => 'You have successfully retrieved a list of transactions' + ]; + } + + /** @var ListsTransactions */ + private $listsTransactions; + + + + public function logic(Request $request) : JsonResponse + { + + $query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters'))); + + return $this->collectionResponse(TransactionUrgentResource::collection($query)); + + } + + + +} diff --git a/app/Http/Controllers/Transactions/ListUrgentTransactionsController.php b/app/Http/Controllers/Transactions/ListUrgentTransactionsController.php new file mode 100644 index 00000000..b97cba14 --- /dev/null +++ b/app/Http/Controllers/Transactions/ListUrgentTransactionsController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Resources/TransactionUrgentResource.php b/app/Http/Resources/TransactionUrgentResource.php new file mode 100644 index 00000000..8b795fe8 --- /dev/null +++ b/app/Http/Resources/TransactionUrgentResource.php @@ -0,0 +1,71 @@ +type, [TransactionType::BILL, TransactionType::REFUND, TransactionType::SUPPLIER_REFUND])){ + $booking = $this->owner->owner; + $bank = $this->owner->bank ?? $booking->bank; + } + else{ + $booking = $this->owner; + $bank = $this->bank ?? $booking->bank; + } + //Check if Transaction of type PAYMENT has an override for recipient bank - ends + $days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); + + return [ + 'id' => $this->id, + 'booking' => new BookingResource($booking), + // 'type' => (int) $this->type, + // 'bill_no' => $this->bill_no, + // 'payment_reference' => $this->payment_reference, + // 'payment_method' => (float) $this->payment_method, + 'recipient_bank_account' => new BankResource($bank), + // 'issuer_name' => $this->issuerCompany->name, + // 'issuer_id' => $this->issuerCompany->id, + // 'amount' => (double) ($this->type === TransactionType::SUPPLIER_REFUND ? $this->amount - $this->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->sum('amount') : $this->amount), + 'original_amount' => (double) ($this->type === TransactionType::SUPPLIER_REFUND ? $this->original_amount - $this->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->sum('original_amount') : $this->original_amount), + // 'currency' => new CurrencyResource($this->currency), + // 'original_currency' => new CurrencyResource($this->original_currency), + // 'service_charge' => (double) $this->service_charge, + // 'tax' => (double) $this->tax, + // 'currency_rate' => (double) $this->currency_rate, + // 'status' => (int) $this->status, + //'details' => TransactionDetailResource::collection($this->transactionDetails), + 'documents' => new DocumentResource($this->documents()->first()), + //'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())), + //'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())), + //'refunded_amount' => $this->booking ? floatval((App()->make(CalculatesBookingRefundAmount::class))->calculateRefundAmount($this->resource, $this->booking->fix_currency_id)) : null, + // 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'), + 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), + // 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'), + 'interval' => [ + 'value' => $days->gt(Carbon::now()) ? '+' : '-', + 'duration' => $days->diff(Carbon::now())->format('%d'), + ], + //'remarks' => RemarkResource::collection($this->remarks), + //'redemption' => new VoucherRedemptionResource($this->voucherRedemption), + // 'bank' => ((int) $this->type === TransactionType::PAYMENT) ? new BankResource($bank) : null, //When a transaction (of type payment) has an override recipient bank details on booking, this is NOT null + ]; + } +} diff --git a/resources/assets/vue/components/bookings/sections/UrgentListSectionComponent.vue b/resources/assets/vue/components/bookings/sections/UrgentListSectionComponent.vue index 1148837c..8a7d339d 100644 --- a/resources/assets/vue/components/bookings/sections/UrgentListSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/UrgentListSectionComponent.vue @@ -48,7 +48,7 @@ }, methods: { fetchList(Page = 1){ - this.submit(route('api.transaction.list') + '?page='+ Page +'&filters=' + JSON.stringify({status: 2, type: 1, owner_type: 'App\\Models\\Booking', per_page: 50, order_by: { + this.submit(route('api.transaction.list.urgent') + '?page='+ Page +'&filters=' + JSON.stringify({status: 2, type: 1, owner_type: 'App\\Models\\Booking', per_page: 50, order_by: { column: 'created_at', DESC: true }}), 'get', 'urgentListSection', false, true) @@ -59,4 +59,4 @@ } } } - \ No newline at end of file + diff --git a/routes/transaction.php b/routes/transaction.php index 4d18c31b..fd3e1f64 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -6,6 +6,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::get('/list', 'ListTransactionsController@list')->name('list'); Route::get('/list/job', 'ListTransactionsJobController@list')->name('list.job'); + Route::get('/list/urgent', 'ListUrgentTransactionsController@list')->name('list.urgent'); Route::delete('/suspend/{id}', 'SuspendTransactionController@suspend')->name('suspend'); route::post('/supplier/{id}/bill/create', 'CreateSupplierTransactionController@create')->name('supplier.create'); From 10b0e2340c7695b48ba0e44b06f0c84d9444e640 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 15 Oct 2024 15:15:07 +0800 Subject: [PATCH 02/19] Laravel Vapor - Fix a 504 error at /bookings/urgent page --- .../BookingForTransactionUrgentResource.php | 73 +++++++++++++++++++ .../Resources/TransactionUrgentResource.php | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 app/Http/Resources/BookingForTransactionUrgentResource.php diff --git a/app/Http/Resources/BookingForTransactionUrgentResource.php b/app/Http/Resources/BookingForTransactionUrgentResource.php new file mode 100644 index 00000000..73d83dc3 --- /dev/null +++ b/app/Http/Resources/BookingForTransactionUrgentResource.php @@ -0,0 +1,73 @@ + $this->id, + 'company' => new CompanyResource($this->company), + 'bank' => new BankResource($this->bank), + 'service' => new ServiceTypeResource($this->service), + 'marking' => $this->marking, + // 'amount' => $this->fix_amount, + // 'floating_amount' => floatval((App()->make(CalculatesBookingFloatingAmount::class))->execute($this->resource, $this->fix_currency_id)), + // 'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), + // // 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) + floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), + // 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)), + // 'fixed_currency' => new CurrencyResource($this->fixedCurrency), + // 'convertible_currency' => new CurrencyResource($this->convertibleCurrency), + // 'conversion_currency' => new CurrencyResource($this->conversionCurrency), + // 'documents' => [ + // 'purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()), + // 'delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), + // 'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()), + // 'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), + // 'proforma_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->orderByDesc('id')->first()), + // 'ecommerce_purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first()), + // ], + // 'order_reference_no' => $this->modelAttributes()->where('name', BookingAttributeNames::ORDER_REFERENCE_NO)->get()->map(function ($attr) { + // return [ + // 'id' => $attr->id, + // 'value' => $attr->value + // ]; + // }), + // 'status' => $this->status, + // 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), + // 'created_at_with_time' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'), + // $this->mergeWhen($this->relationLoaded('transactions'), [ + // 'purchase_order' => new TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()), + // 'payment_attempts' => TransactionResource::collection( + // $this->transactions() + // ->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION) + // ->whereDate('expires_on', '>=', Carbon::now()) + // ->get() + // ), + // // 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()), + // 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::EXPIRED)->get()), + // 'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){ + // $query->where(function($query){ + // $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED, ApprovalStatus::REFUNDED]); + // })->orWhere(function($query){ + // $query->where(function($query){ + // $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]); + // })->orWhere(function($query){ + // $query->where('type', TransactionType::CREDIT_NOTE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + // }); + // }); + // })->latest()->get()) + // ]) + ]; + } +} diff --git a/app/Http/Resources/TransactionUrgentResource.php b/app/Http/Resources/TransactionUrgentResource.php index 8b795fe8..c36b8de8 100644 --- a/app/Http/Resources/TransactionUrgentResource.php +++ b/app/Http/Resources/TransactionUrgentResource.php @@ -35,7 +35,7 @@ class TransactionUrgentResource extends JsonResource return [ 'id' => $this->id, - 'booking' => new BookingResource($booking), + 'booking' => new BookingForTransactionUrgentResource($booking), // 'type' => (int) $this->type, // 'bill_no' => $this->bill_no, // 'payment_reference' => $this->payment_reference, From c9d3bc4b93b10af21ffb649c70d9bf0c5d187fec Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 15 Oct 2024 15:40:49 +0800 Subject: [PATCH 03/19] Laravel Vapor - Fix a 504 error at /bookings/urgent page --- .../DocumentForTransactionUrgentResource.php | 29 +++++++++++++++++++ .../Resources/TransactionUrgentResource.php | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app/Http/Resources/DocumentForTransactionUrgentResource.php diff --git a/app/Http/Resources/DocumentForTransactionUrgentResource.php b/app/Http/Resources/DocumentForTransactionUrgentResource.php new file mode 100644 index 00000000..59c581c6 --- /dev/null +++ b/app/Http/Resources/DocumentForTransactionUrgentResource.php @@ -0,0 +1,29 @@ + $this->id, + // 'reference' => $this->reference, + // 'status' => (int) $this->status, + // 'document_type' => $this->document_type, + // 'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingResource($this->owner) : new CompanyResource($this->owner)) : null, + // 'files' => FileResource::collection($this->files), + 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A') + ]; + } +} diff --git a/app/Http/Resources/TransactionUrgentResource.php b/app/Http/Resources/TransactionUrgentResource.php index c36b8de8..04edd0d1 100644 --- a/app/Http/Resources/TransactionUrgentResource.php +++ b/app/Http/Resources/TransactionUrgentResource.php @@ -52,7 +52,7 @@ class TransactionUrgentResource extends JsonResource // 'currency_rate' => (double) $this->currency_rate, // 'status' => (int) $this->status, //'details' => TransactionDetailResource::collection($this->transactionDetails), - 'documents' => new DocumentResource($this->documents()->first()), + 'documents' => new DocumentForTransactionUrgentResource($this->documents()->first()), //'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())), //'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())), //'refunded_amount' => $this->booking ? floatval((App()->make(CalculatesBookingRefundAmount::class))->calculateRefundAmount($this->resource, $this->booking->fix_currency_id)) : null, From 258a20f118c32f22437a74fb233b15a92a6c81a8 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 15 Oct 2024 16:02:23 +0800 Subject: [PATCH 04/19] Laravel Vapor - Fix a 504 error at /bookings/urgent page --- app/Http/Resources/BookingForTransactionUrgentResource.php | 2 +- .../components/bookings/elements/UrgentTransactionComponent.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/BookingForTransactionUrgentResource.php b/app/Http/Resources/BookingForTransactionUrgentResource.php index 73d83dc3..418c3a86 100644 --- a/app/Http/Resources/BookingForTransactionUrgentResource.php +++ b/app/Http/Resources/BookingForTransactionUrgentResource.php @@ -17,7 +17,7 @@ class BookingForTransactionUrgentResource extends JsonResource { return [ 'id' => $this->id, - 'company' => new CompanyResource($this->company), + 'company_reference' => $this->company->reference, //new CompanyResource($this->company) 'bank' => new BankResource($this->bank), 'service' => new ServiceTypeResource($this->service), 'marking' => $this->marking, diff --git a/resources/assets/vue/components/bookings/elements/UrgentTransactionComponent.vue b/resources/assets/vue/components/bookings/elements/UrgentTransactionComponent.vue index b684c6cc..00dd9586 100644 --- a/resources/assets/vue/components/bookings/elements/UrgentTransactionComponent.vue +++ b/resources/assets/vue/components/bookings/elements/UrgentTransactionComponent.vue @@ -18,7 +18,7 @@

{{item.recipient_bank_account.type === 3 ? item.recipient_bank_account.account_no : item.recipient_bank_account.account_no.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim()}}

-

{{item.booking.company.reference}}

+

{{item.booking.company_reference}}

{{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}

From 3b54107a30e4b2c3f1bb1d6be3fbe3faf5566dcc Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 02:16:28 +0800 Subject: [PATCH 05/19] Laravel Vapor - Deployment day to production, update domain + enable schedule tasks --- app/Console/Kernel.php | 26 ++++++++++++-------------- vapor.yml | 4 +++- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index b4a3c863..fc9d5d5f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -50,23 +50,21 @@ class Kernel extends ConsoleKernel ->withoutOverlapping(); if(env('APP_ENV') === 'production'){ - //cief todo: disable commands to avoid unintentional interfering with production starts - // $schedule->command('email-do-to-vt-command') - // ->dailyAt('10:00') - // ->withoutOverlapping(); + $schedule->command('email-do-to-vt-command') + ->dailyAt('10:00') + ->withoutOverlapping(); - // $schedule->command('seasonal-segmant-company-remove-command') - // ->dailyAt('01:00') - // ->withoutOverlapping(); + $schedule->command('seasonal-segmant-company-remove-command') + ->dailyAt('01:00') + ->withoutOverlapping(); - // $schedule->command('delete-bulk-download-files-command') - // ->hourly() - // ->withoutOverlapping(); + $schedule->command('delete-bulk-download-files-command') + ->hourly() + ->withoutOverlapping(); - // $schedule->command('booking-expired-command') - // ->dailyAt('02:00') - // ->withoutOverlapping(); - //cief todo: disable commands to avoid unintentional interfering with production + $schedule->command('booking-expired-command') + ->dailyAt('02:00') + ->withoutOverlapping(); // DISABLED BY DEFAULT // $schedule->command('purchase-order-autofill-command') diff --git a/vapor.yml b/vapor.yml index f97a0f56..95513481 100644 --- a/vapor.yml +++ b/vapor.yml @@ -3,7 +3,9 @@ name: exchange separate-vendor: true environments: production: - domain: production.exchange.izyim.com + domain: + - production.exchange.izyim.com + - exchange.cief-malaysia.com memory: 1024 cli-memory: 512 queues: From 75af3516f343ee06f1ab7a34d183f9a50a9e1c26 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 04:14:07 +0800 Subject: [PATCH 06/19] Laravel Vapor - Code cleanup --- resources/assets/vue/vuex/modules/crudRequest.js | 2 +- resources/assets/vue/vuex/modules/crudRequestV2.js | 2 +- routes/web.php | 14 +------------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/resources/assets/vue/vuex/modules/crudRequest.js b/resources/assets/vue/vuex/modules/crudRequest.js index 80c54afb..49008223 100644 --- a/resources/assets/vue/vuex/modules/crudRequest.js +++ b/resources/assets/vue/vuex/modules/crudRequest.js @@ -12,7 +12,7 @@ export default { let decodedParams = fullyDecodeURI(encodedParams); const queryParams = encodeURIComponent(decodedParams); queryDomain = encodeUrlWithoutQueryParameter(queryDomain) - console.log("queryDomain: " + queryDomain); + encodedParams = queryParams.toString(); let filteredEncodedParams = encodedParams.replace(/%3D/g,'='); filteredEncodedParams = filteredEncodedParams.replace(/%26/g,'&'); diff --git a/resources/assets/vue/vuex/modules/crudRequestV2.js b/resources/assets/vue/vuex/modules/crudRequestV2.js index 578d9564..6d1dc568 100644 --- a/resources/assets/vue/vuex/modules/crudRequestV2.js +++ b/resources/assets/vue/vuex/modules/crudRequestV2.js @@ -8,7 +8,7 @@ export default { let decodedParams = fullyDecodeURI(encodedParams); const queryParams = encodeURIComponent(decodedParams); queryDomain = encodeUrlWithoutQueryParameter(queryDomain) - console.log("queryDomain: " + queryDomain); + encodedParams = queryParams.toString(); let filteredEncodedParams = encodedParams.replace(/%3D/g,'='); filteredEncodedParams = filteredEncodedParams.replace(/%26/g,'&'); diff --git a/routes/web.php b/routes/web.php index 6a6a6d67..9dd755d2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1233,19 +1233,7 @@ Route::get('check-duplicate-refunds', function () { echo ''; }); -//Laravel Vapor - Starts -// Route::get('/aws-image-upload', 'AWS\AWSImageUploadController@imageUpload')->name('aws.image.upload'); -// Route::post('/aws-image-upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post'); -// Route::get('/aws-image/{filename}', 'AWS\AWSImageUploadController@displayImage')->name('aws.image.displayImage'); - -// Route::get('/token', function (Request $request) { -// $token = $request->session()->token(); -// echo $token; -// $token = csrf_token(); -// echo $token; -// }); - Route::get('/downloads', function () { return view('pages.downloads.index'); })->name('admin.download'); -//Laravel Vapor - Ends + From b8a38ba11ec91069db232019b608f3a1dac01f36 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 05:26:50 +0800 Subject: [PATCH 07/19] Laravel Vapor - Fix Export in Excel through S3 bucket --- .../bookings/elements/TransactionGroupComponent.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/TransactionGroupComponent.vue b/resources/assets/vue/components/bookings/elements/TransactionGroupComponent.vue index 2e7c30c5..26357b42 100644 --- a/resources/assets/vue/components/bookings/elements/TransactionGroupComponent.vue +++ b/resources/assets/vue/components/bookings/elements/TransactionGroupComponent.vue @@ -26,11 +26,16 @@ - + + + + --> - + - + + + + diff --git a/resources/assets/vue/components/general/elements/OpenLinkInNewTabComponent.vue b/resources/assets/vue/components/general/elements/OpenLinkInNewTabComponent.vue index 971c8ed2..145dd0f7 100644 --- a/resources/assets/vue/components/general/elements/OpenLinkInNewTabComponent.vue +++ b/resources/assets/vue/components/general/elements/OpenLinkInNewTabComponent.vue @@ -2,9 +2,10 @@ + @click.prevent="handleClick" + v-tooltip:top="tooltip ? tooltip : ''"> - + @@ -23,7 +24,15 @@ customClass:{ type: String, default: '' - } + }, + tooltip:{ + type: String, + default: '' + }, + showSpinner: { + type: Boolean, + default: true + }, }, data() { return { diff --git a/routes/web.php b/routes/web.php index 9dd755d2..90711eaf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,7 +36,7 @@ use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionWithInvo use App\Classes\Modules\Transactions\Services\DeletesTransaction; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; - +use App\Classes\General\AWSS3Helper; /* |-------------------------------------------------------------------------- @@ -621,7 +621,15 @@ Route::get('/group/invoice/{id}', function ($id) { $dompdf->setPaper('A4', 'portrait'); $dompdf->render(); - return $dompdf->stream("invoice_pdf_{$supplier->name}.pdf"); + $exportFileName = "invoice_pdf_{$supplier->name}.pdf"; + $filesystemDriver = Storage::getDefaultDriver(); + if($filesystemDriver === 's3'){ + $pdfContent = $dompdf->output(); + return response([ 'src' => AWSS3Helper::S3PDF($exportFileName, $pdfContent) ]); + } + else{ + return $dompdf->stream($exportFileName); + } })->name('group.invoice'); Route::get('/wallet/audit', function (Request $request) { From 36e6e0638fd261ecfa4dc184a4c7dfd53b9d177b Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 12:59:00 +0800 Subject: [PATCH 09/19] Laravel Vapor - Debug uploading issue --- .../Processors/CreateInvoiceDocumentProcessor.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index 2be4a3fb..c4f447a0 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -50,6 +50,12 @@ class CreateInvoiceDocumentProcessor $oMerger = PDFMerger::init(); + + $saveDirectory = storage_path('app/documents'); + if (!file_exists($saveDirectory)) { + mkdir($saveDirectory, 0755, true); + } + $order_pdf->save(storage_path('app/documents/temp.pdf')); $oMerger->addPDF(storage_path('app/documents/temp.pdf'), 'all'); From 7c90589fac95c40f45f88d338b261b405041092e Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 13:27:42 +0800 Subject: [PATCH 10/19] Laravel Vapor - Debug approve purchase order issue --- .../Processors/CreateInvoiceDocumentProcessor.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index c4f447a0..e1516d66 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -8,6 +8,7 @@ use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\DocumentType; use App\Models\Document; +use Illuminate\Support\Facades\Log; use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf; use Webklex\PDFMerger\Facades\PDFMergerFacade as PDFMerger; use Illuminate\Support\Facades\Storage; @@ -61,10 +62,18 @@ class CreateInvoiceDocumentProcessor $oMerger->addPDF(storage_path('app/documents/temp.pdf'), 'all'); $filesystemDriver = Storage::getDefaultDriver(); foreach ($purchaseOrderDocuments as $document){ - $localFilePath = storage_path('app/documents/' . $document->files()->first()->file->file_info->original->file); + $currentFile = $document->files()->first()->file->file_info->original->file; + if($filesystemDriver === 's3'){ + Log::info('CreateInvoiceDocumentProcessor 1: ' . $currentFile); + $fileContent = Storage::disk('s3')->get($currentFile); + Storage::put('app/documents/' . $currentFile, $fileContent); + } + + $localFilePath = storage_path('app/documents/' . $currentFile); $oMerger->addPDF($localFilePath, 'all'); if($filesystemDriver === 's3'){ - $filePathForS3 = 'documents/'.$document->files()->first()->file->file_info->original->file; + $filePathForS3 = 'documents/'.$currentFile; + Log::info('CreateInvoiceDocumentProcessor 2: ' . $filePathForS3); Storage::disk('s3')->put($filePathForS3, file_get_contents($localFilePath)); } } From 2cf51d172e8d4ada0455ed105476edf4b67c047c Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 13:49:27 +0800 Subject: [PATCH 11/19] Laravel Vapor - Debug approve purchase order issue --- .../Processors/CreateInvoiceDocumentProcessor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index e1516d66..f3a04cd9 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -66,7 +66,9 @@ class CreateInvoiceDocumentProcessor if($filesystemDriver === 's3'){ Log::info('CreateInvoiceDocumentProcessor 1: ' . $currentFile); $fileContent = Storage::disk('s3')->get($currentFile); - Storage::put('app/documents/' . $currentFile, $fileContent); + $filepath = storage_path('app/documents/' . $currentFile); + file_put_contents($filepath, $fileContent); + // Storage::put('app/documents/' . $currentFile, $fileContent); } $localFilePath = storage_path('app/documents/' . $currentFile); From e92f24e57b9d7a3dce0dabd37ac7c76234b7dbe1 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 14:05:54 +0800 Subject: [PATCH 12/19] Laravel Vapor - Debug approve purchase order issue --- .../Processors/CreateInvoiceDocumentProcessor.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index f3a04cd9..a3456b63 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -67,6 +67,10 @@ class CreateInvoiceDocumentProcessor Log::info('CreateInvoiceDocumentProcessor 1: ' . $currentFile); $fileContent = Storage::disk('s3')->get($currentFile); $filepath = storage_path('app/documents/' . $currentFile); + $directoryPath = dirname($filepath); + if (!file_exists($directoryPath)) { + mkdir($directoryPath, 0755, true); + } file_put_contents($filepath, $fileContent); // Storage::put('app/documents/' . $currentFile, $fileContent); } From 118efc734cd01bbfb97286ecf12cb0dce59e3648 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 14:30:21 +0800 Subject: [PATCH 13/19] Laravel Vapor - Debug approve purchase order issue --- .../Processors/CreateInvoiceDocumentProcessor.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index a3456b63..90445088 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -77,16 +77,19 @@ class CreateInvoiceDocumentProcessor $localFilePath = storage_path('app/documents/' . $currentFile); $oMerger->addPDF($localFilePath, 'all'); - if($filesystemDriver === 's3'){ - $filePathForS3 = 'documents/'.$currentFile; - Log::info('CreateInvoiceDocumentProcessor 2: ' . $filePathForS3); - Storage::disk('s3')->put($filePathForS3, file_get_contents($localFilePath)); - } } $oMerger->merge(); $order_pdf = $oMerger; + + if($filesystemDriver === 's3'){ + $finalTempPdfPath = storage_path('app/documents/temp.pdf'); + $filePathForS3 = 'documents/temp.pdf'; + $fileContent = file_get_contents($finalTempPdfPath); + Log::info('CreateInvoiceDocumentProcessor 2: ' . $filePathForS3); + Storage::disk('s3')->put($filePathForS3, $fileContent); + } } $document_object = new DocumentObject( From 9f020cd4090f46a7a5ef38055d6fde97ec663417 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 14:44:49 +0800 Subject: [PATCH 14/19] Laravel Vapor - Debug approve purchase order issue --- .../Transactions/Processors/CreateInvoiceDocumentProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index 90445088..87e39013 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -85,7 +85,7 @@ class CreateInvoiceDocumentProcessor if($filesystemDriver === 's3'){ $finalTempPdfPath = storage_path('app/documents/temp.pdf'); - $filePathForS3 = 'documents/temp.pdf'; + $filePathForS3 = 'documents/temp/temp.pdf'; $fileContent = file_get_contents($finalTempPdfPath); Log::info('CreateInvoiceDocumentProcessor 2: ' . $filePathForS3); Storage::disk('s3')->put($filePathForS3, $fileContent); From 47bf3d0bcdd94f227bdef5bc9bb2059b4ca9cbf8 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 14:47:25 +0800 Subject: [PATCH 15/19] Laravel Vapor - Debug approve purchase order issue --- .../Transactions/Processors/CreateInvoiceDocumentProcessor.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index 87e39013..899bff7b 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -72,7 +72,6 @@ class CreateInvoiceDocumentProcessor mkdir($directoryPath, 0755, true); } file_put_contents($filepath, $fileContent); - // Storage::put('app/documents/' . $currentFile, $fileContent); } $localFilePath = storage_path('app/documents/' . $currentFile); @@ -87,7 +86,7 @@ class CreateInvoiceDocumentProcessor $finalTempPdfPath = storage_path('app/documents/temp.pdf'); $filePathForS3 = 'documents/temp/temp.pdf'; $fileContent = file_get_contents($finalTempPdfPath); - Log::info('CreateInvoiceDocumentProcessor 2: ' . $filePathForS3); + Log::info('CreateInvoiceDocumentProcessor 2 filePathForS3: ' . $filePathForS3); Storage::disk('s3')->put($filePathForS3, $fileContent); } } From 039f0309234c9da9e5d53ed233ff49f283ba91fc Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 15:08:24 +0800 Subject: [PATCH 16/19] Laravel Vapor - Debug approve purchase order issue --- .../Transactions/Processors/CreateInvoiceDocumentProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index 899bff7b..1aa5210b 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -84,7 +84,7 @@ class CreateInvoiceDocumentProcessor if($filesystemDriver === 's3'){ $finalTempPdfPath = storage_path('app/documents/temp.pdf'); - $filePathForS3 = 'documents/temp/temp.pdf'; + $filePathForS3 = 'temp/temp.pdf'; $fileContent = file_get_contents($finalTempPdfPath); Log::info('CreateInvoiceDocumentProcessor 2 filePathForS3: ' . $filePathForS3); Storage::disk('s3')->put($filePathForS3, $fileContent); From 866ce4e01116e74f8c9b5661d5d8818b207a28c7 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 15:35:23 +0800 Subject: [PATCH 17/19] Laravel Vapor - Debug uploading issue --- .../vue/components/general/forms/FileUploadComponent.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/general/forms/FileUploadComponent.vue b/resources/assets/vue/components/general/forms/FileUploadComponent.vue index 15594912..3807ff01 100644 --- a/resources/assets/vue/components/general/forms/FileUploadComponent.vue +++ b/resources/assets/vue/components/general/forms/FileUploadComponent.vue @@ -97,11 +97,16 @@ vm.isLoading = true; + const pdfIconUrl = "https://assets.izyim.com/public/images/icons/pdf.png"; + const xlsIconUrl = "https://assets.izyim.com/public/images/icons/xlsx.png"; + if(file.name.split('.').pop() === 'pdf'){ - $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/pdf.png")); + // $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/pdf.png")); + $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", pdfIconUrl); } if(file.name.split('.').pop().indexOf("xls") !== -1){ - $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/xlsx.png")); + // $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/xlsx.png")); + $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", xlsIconUrl); } Promise.all(dropzone.files.map(function(file){ From 65e374b984f88587ead8ca4e1eb3cab8bf3e8545 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 15:45:25 +0800 Subject: [PATCH 18/19] Laravel Vapor - Debug uploading issue --- .../vue/components/general/forms/FileUploadComponent.vue | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/resources/assets/vue/components/general/forms/FileUploadComponent.vue b/resources/assets/vue/components/general/forms/FileUploadComponent.vue index 3807ff01..15594912 100644 --- a/resources/assets/vue/components/general/forms/FileUploadComponent.vue +++ b/resources/assets/vue/components/general/forms/FileUploadComponent.vue @@ -97,16 +97,11 @@ vm.isLoading = true; - const pdfIconUrl = "https://assets.izyim.com/public/images/icons/pdf.png"; - const xlsIconUrl = "https://assets.izyim.com/public/images/icons/xlsx.png"; - if(file.name.split('.').pop() === 'pdf'){ - // $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/pdf.png")); - $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", pdfIconUrl); + $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/pdf.png")); } if(file.name.split('.').pop().indexOf("xls") !== -1){ - // $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/xlsx.png")); - $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", xlsIconUrl); + $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/xlsx.png")); } Promise.all(dropzone.files.map(function(file){ From e96fc3adb2252b193e61028de6a46f4073857aae Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 16 Oct 2024 15:49:42 +0800 Subject: [PATCH 19/19] Laravel Vapor - Debug uploading issue --- .../vue/components/general/forms/FileUploadComponent.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/general/forms/FileUploadComponent.vue b/resources/assets/vue/components/general/forms/FileUploadComponent.vue index 15594912..3807ff01 100644 --- a/resources/assets/vue/components/general/forms/FileUploadComponent.vue +++ b/resources/assets/vue/components/general/forms/FileUploadComponent.vue @@ -97,11 +97,16 @@ vm.isLoading = true; + const pdfIconUrl = "https://assets.izyim.com/public/images/icons/pdf.png"; + const xlsIconUrl = "https://assets.izyim.com/public/images/icons/xlsx.png"; + if(file.name.split('.').pop() === 'pdf'){ - $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/pdf.png")); + // $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/pdf.png")); + $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", pdfIconUrl); } if(file.name.split('.').pop().indexOf("xls") !== -1){ - $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/xlsx.png")); + // $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", asset("images/icons/xlsx.png")); + $(file.previewElement).closest("img[data-dz-thumbnail]").attr("src", xlsIconUrl); } Promise.all(dropzone.files.map(function(file){