From 531b65686ff1d5040d4edaff1ff1af806c517087 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 16 May 2024 10:56:02 +0800 Subject: [PATCH] export white form transactions --- .../Services/ExportsWhiteFormTransactions.php | 99 +++++++++++++++++++ .../ExportCustomersToExcelController.php | 8 ++ .../DownloadBillingWithDatesComponent.vue | 29 +++++- .../DownloadSupplierWhiteFormComponent.vue | 8 +- routes/web.php | 1 + 5 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 app/Classes/Modules/Exports/Services/ExportsWhiteFormTransactions.php diff --git a/app/Classes/Modules/Exports/Services/ExportsWhiteFormTransactions.php b/app/Classes/Modules/Exports/Services/ExportsWhiteFormTransactions.php new file mode 100644 index 00000000..78579fc1 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsWhiteFormTransactions.php @@ -0,0 +1,99 @@ +request = $request; + } + + public function headings(): array + { + return [ + 'Bank Name', + 'Bank Details', + 'Bank Acc No.', + 'Order amount', + 'Booking Reference', + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $start_date = $this->request->input('startDate', null); + if ($start_date) { + $start_date = Carbon::parse($this->request->input('startDate'))->format('Y-m-d'); + } + + $end_date = $this->request->input('endDate', null); + if ($end_date) { + $end_date = Carbon::parse($this->request->input('endDate'))->format('Y-m-d'); + } + + $query = Group::query(); + + // todo-new: confirm this + // $query->where('type', ::PAYMENT)->where('payment_method', '!=', PaymentMethodType::WALLET); + // $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + + if ($start_date && $end_date) { + $query->whereBetween('created_at', [ + Carbon::parse($start_date)->format('Y-m-d 0:00:00'), + Carbon::parse($end_date)->format('Y-m-d 23:59:59') + ]); + } elseif ($start_date && !$end_date) { + $query->where('created_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00')); + } elseif (!$start_date && $end_date) { + $query->where('created_at', '<=', Carbon::parse($end_date)->format('Y-m-d 23:59:59')); + } + + return $query; + } + + /** + * @param Company $group + * + * @return array + */ + public function map($group): array + { + $supplier = $group->issuerCompany; + $supplerBank = $supplier->banks->first(); + + $bank_name = $supplerBank->bank_name; + $holder_name = $supplerBank->holder_name; + $account_no = $supplerBank->account_no; + + $bookingReference = $group->transactions()->get()->pluck('owner.owner.marking')->toArray(); + + return [ + $bank_name, + $holder_name, + $account_no, + $group->amount, + implode(",", $bookingReference) + ]; + } +} diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 0f351c7d..7e484c6c 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -19,6 +19,7 @@ use App\Classes\Modules\Exports\Services\ExportsImportedInvoiceMappeds; use App\Models\TransactionMappingLog; use App\Classes\Modules\Exports\Services\ExportsReceiptTransactions; use App\Classes\Modules\Exports\Services\ExportsImportedReceiptMappeds; +use App\Classes\Modules\Exports\Services\ExportsWhiteFormTransactions; class ExportCustomersToExcelController { @@ -54,6 +55,13 @@ class ExportCustomersToExcelController return $response; } + public function whiteFormTransactions(Request $request){ + $exportsTransactions = new ExportsWhiteFormTransactions($request); + $response = $exportsTransactions->download('white-form-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } + public function walletTransactions(Request $request){ $exportsTransactions = new ExportsWalletTransactions($request); $response = $exportsTransactions->download('wallet-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); diff --git a/resources/assets/vue/components/bookings/elements/DownloadBillingWithDatesComponent.vue b/resources/assets/vue/components/bookings/elements/DownloadBillingWithDatesComponent.vue index 99be4562..2d89690e 100644 --- a/resources/assets/vue/components/bookings/elements/DownloadBillingWithDatesComponent.vue +++ b/resources/assets/vue/components/bookings/elements/DownloadBillingWithDatesComponent.vue @@ -16,6 +16,12 @@ +
+ + + + +
@@ -46,9 +52,20 @@ export default { parameters: { startDate: '', endDate: '', + reportType: '', }, } }, + mounted(){ + switch(this.section) { + case 'paymentsReportSection': + this.parameters.reportType = 'Payments Report' + break; + case 'walletsReportSection': + this.parameters.reportType = 'Wallets Report' + break; + } + }, validations: { parameters: { startDate: { @@ -57,19 +74,25 @@ export default { endDate: { required }, + reportType: { + required + }, } }, methods: { downloadReport(){ var apiRoute = ''; if(!this.validate()){ return; } - switch(this.section) { - case 'paymentsReportSection': + switch(this.parameters.reportType) { + case 'Payments Report': apiRoute = route('paymentTransactions.export'); break; - case 'walletsReportSection': + case 'Wallets Report': apiRoute = route('walletTransactions.export'); break; + case 'White Form Report': + apiRoute = route('whiteFormTransactions.export'); + break; } window.open(apiRoute + '?startDate=' + this.parameters.startDate + '&endDate=' + this.parameters.endDate, '_blank'); }, diff --git a/resources/assets/vue/components/bookings/elements/DownloadSupplierWhiteFormComponent.vue b/resources/assets/vue/components/bookings/elements/DownloadSupplierWhiteFormComponent.vue index 827557ea..cbf8bd48 100644 --- a/resources/assets/vue/components/bookings/elements/DownloadSupplierWhiteFormComponent.vue +++ b/resources/assets/vue/components/bookings/elements/DownloadSupplierWhiteFormComponent.vue @@ -4,25 +4,25 @@
-
+
-
+
-
+
-
+
Export diff --git a/routes/web.php b/routes/web.php index 0d14a526..e797557a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -281,6 +281,7 @@ Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\Export Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor')->name('newDebtor.export'); Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export'); +Route::get('/export/white-form-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@whiteFormTransactions')->name('whiteFormTransactions.export'); Route::get('/export/wallet-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@walletTransactions')->name('walletTransactions.export'); Route::get('/export/booking-transactions', 'Exports\ExportCustomersToExcelController@bookingTransactions')->name('export.transactions.booking'); Route::get('/export/invoice-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@invoiceTransactions')->name('invoiceTransactions.export');