diff --git a/app/Classes/Modules/Exports/Services/ExportsV2Transactions.php b/app/Classes/Modules/Exports/Services/ExportsV2Transactions.php new file mode 100644 index 00000000..007293c2 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsV2Transactions.php @@ -0,0 +1,104 @@ +startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(1); + $this->endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now(); + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + return Transaction::whereBetween('created_at', [$this->startDate, $this->endDate]) //Limit, 'expensive' query; + ->whereIn('type', [TransactionType::PAYMENT, TransactionType::BILL]) + ->where('owner_type', '!=', Wallet::class); + } + + /** + * @param $transaction + * @return array + */ + public function map($transaction): array + { + $transactionTypes = [ + 0 => 'PAYMENT_ATTEMPT', + 1 => 'PAYMENT', + 2 => 'INVOICE', + 3 => 'BILL', + 4 => 'PROFORMA', + 5 => 'TOP_UP', + 6 => 'REFUND', + 7 => 'PURCHASE_ORDER', + 8 => 'SUPPLIER_DELIVER', + 9 => 'CREDIT_NOTE', + 10 => 'WITHDRAW', + 11 => 'DEBIT_NOTE', + 12 => 'TRANSFER_FEE' + ]; + + $transactionStatus = [ + 0 => 'PENDING_SUBMISSION', + 1 => 'PENDING_VERIFICATION', + 2 => 'APPROVED', + 3 => 'COMPLETED', + 4 => 'REJECTED', + 5 => 'SUSPENDED', + 6 => 'EXPIRED' + ]; + + + $booking = $transaction->owner; + if(!($booking instanceof Booking)){ + $booking = $booking->owner; + } + + $company = $booking->company; + + if(!$company instanceof Company) dd($transaction); + + return [ + $company->reference, + $booking ? $booking->marking : '', + $transaction->bill_no, + $transaction->owner_id, + $transaction->owner_type, + $transactionTypes[$transaction->type], + $transaction->issuerCompany->name, + $transaction->reciver, + $transaction->currency->short_code, + $transaction->amount, + $transaction->original_currency->short_code, + $transaction->original_amount, + $transaction->currency_rate, + $transaction->tax, + $transaction->service_charge, + isset($transactionStatus[$transaction->status]) ? $transactionStatus[$transaction->status] : 'Unknown Status', + \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel($transaction->created_at), + \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel($transaction->updated_at), + ]; + } +} diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 91ace417..b693f326 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -6,6 +6,7 @@ namespace App\Http\Controllers\Exports; use App\Classes\Modules\Exports\Services\ExportCurrencyVendorOrder; use App\Classes\Modules\Exports\Services\ExportsCustomers; use App\Classes\Modules\Exports\Services\ExportsTransactions; +use App\Classes\Modules\Exports\Services\ExportsV2Transactions; use App\Classes\Modules\Exports\Services\ExportsBookingTransactions; use App\Classes\Modules\Exports\Services\ExportsLeadsTransactions; use App\Classes\Modules\Exports\Services\ExportsNullDebtors; @@ -23,6 +24,7 @@ use App\Classes\Modules\Exports\Services\ExportsImportedReceiptMappeds; use App\Classes\Modules\Exports\Services\ExportsWhiteFormTransactions; use Illuminate\Support\Facades\Storage; use App\Classes\General\AWSS3Helper; +use Illuminate\Support\Carbon; class ExportCustomersToExcelController { @@ -72,6 +74,39 @@ class ExportCustomersToExcelController } } + public function v2transactions(Request $request){ + + $validated = $request->validate([ + 'startDate' => 'nullable|date_format:d-m-Y', + 'endDate' => 'nullable|date_format:d-m-Y|after_or_equal:startDate', + ]); + + $startDate = null; + $endDate = null; + + if (isset($validated['startDate']) && $validated['startDate']) { + $startDate = Carbon::createFromFormat('d-m-Y', $validated['startDate'])->startOfDay(); + } else { + $startDate = Carbon::now()->subMonths(1)->startOfDay(); + } + + if (isset($validated['endDate']) && $validated['endDate']) { + $endDate = Carbon::createFromFormat('d-m-Y', $validated['endDate'])->endOfDay(); + } else { + $endDate = Carbon::now()->endOfDay(); + } + + $exportsTransactions = new ExportsV2Transactions($startDate, $endDate); + $exportFileName = 'transactions.csv'; + $filesystemDriver = Storage::getDefaultDriver(); + + if ($filesystemDriver === 's3') { + return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $exportsTransactions)]); + } else { + return $exportsTransactions->download($exportFileName, Excel::CSV, ['Content-Type' => 'text/csv']); + } + } + public function nullDebtor(ExportsNullDebtors $exportsNullDebtors, Request $request){ $exportFileName = 'nullDebtor.xls'; $filesystemDriver = Storage::getDefaultDriver(); diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index e14c32c0..c2d20a85 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -21,18 +21,22 @@ class TransactionResource extends JsonResource { $booking = null; //cief todo: 66 $bank = null; + //Check if Transaction of type PAYMENT has an override for recipient bank - starts + $isEditedBankRecipient = false; if(in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND, TransactionType::SUPPLIER_REFUND])){ $booking = $this->owner->owner; $bank = $this->owner->bank ?? $booking->bank; + $isEditedBankRecipient = $this->owner->bank ? true : false; } else{ $booking = $this->owner; $bank = $this->bank ?? $booking->bank; + $isEditedBankRecipient = $this->bank ? true : false; } //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); + $days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ 'id' => $this->id, 'booking' => new BookingResource($booking), @@ -66,6 +70,7 @@ class TransactionResource extends JsonResource '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 + 'bank_recipient_edited' => $isEditedBankRecipient ]; } } diff --git a/resources/assets/vue/components/accounting/elements/HistoryImportedInvoices.vue b/resources/assets/vue/components/accounting/elements/HistoryImportedInvoices.vue index d0dd1e93..b10721ee 100644 --- a/resources/assets/vue/components/accounting/elements/HistoryImportedInvoices.vue +++ b/resources/assets/vue/components/accounting/elements/HistoryImportedInvoices.vue @@ -41,7 +41,8 @@ successHandler(response) { if(window.LARAVEL_VAPOR_ENABLED){ if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } } }, diff --git a/resources/assets/vue/components/accounting/elements/HistoryImportedReceipts.vue b/resources/assets/vue/components/accounting/elements/HistoryImportedReceipts.vue index 385e37b9..1b37b8ef 100644 --- a/resources/assets/vue/components/accounting/elements/HistoryImportedReceipts.vue +++ b/resources/assets/vue/components/accounting/elements/HistoryImportedReceipts.vue @@ -41,7 +41,8 @@ successHandler(response) { if(window.LARAVEL_VAPOR_ENABLED){ if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } } }, diff --git a/resources/assets/vue/components/accounting/sections/ImportedInvoiceMappedComponent.vue b/resources/assets/vue/components/accounting/sections/ImportedInvoiceMappedComponent.vue index 01194163..9047cc76 100644 --- a/resources/assets/vue/components/accounting/sections/ImportedInvoiceMappedComponent.vue +++ b/resources/assets/vue/components/accounting/sections/ImportedInvoiceMappedComponent.vue @@ -135,7 +135,8 @@ response.json().then(response => { if(!success){return;} if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } }); } diff --git a/resources/assets/vue/components/accounting/sections/ImportedReceiptMappedComponent.vue b/resources/assets/vue/components/accounting/sections/ImportedReceiptMappedComponent.vue index c81532c8..2e595ede 100644 --- a/resources/assets/vue/components/accounting/sections/ImportedReceiptMappedComponent.vue +++ b/resources/assets/vue/components/accounting/sections/ImportedReceiptMappedComponent.vue @@ -139,7 +139,8 @@ response.json().then(response => { if(!success){return;} if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } }); } diff --git a/resources/assets/vue/components/accounting/sections/TransactionsMappingComponent.vue b/resources/assets/vue/components/accounting/sections/TransactionsMappingComponent.vue index b94148ad..0217ed9b 100644 --- a/resources/assets/vue/components/accounting/sections/TransactionsMappingComponent.vue +++ b/resources/assets/vue/components/accounting/sections/TransactionsMappingComponent.vue @@ -281,7 +281,8 @@ export default { response.json().then(response => { if(!success){return;} if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } }); } @@ -309,7 +310,8 @@ export default { response.json().then(response => { if(!success){return;} if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } }); } diff --git a/resources/assets/vue/components/bookings/elements/BillingComponent.vue b/resources/assets/vue/components/bookings/elements/BillingComponent.vue index ba1ce85c..3f8df642 100644 --- a/resources/assets/vue/components/bookings/elements/BillingComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BillingComponent.vue @@ -126,7 +126,8 @@ export default { successHandler(response) { if(window.LARAVEL_VAPOR_ENABLED){ if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } } }, diff --git a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue index 0a0b06bf..76d9d509 100644 --- a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue +++ b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue @@ -130,7 +130,8 @@ export default { response.json().then(response => { if(!success){return;} if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } }); } diff --git a/resources/assets/vue/components/bookings/elements/DownloadBillingWithDatesComponent.vue b/resources/assets/vue/components/bookings/elements/DownloadBillingWithDatesComponent.vue index 195fc7dd..867ee932 100644 --- a/resources/assets/vue/components/bookings/elements/DownloadBillingWithDatesComponent.vue +++ b/resources/assets/vue/components/bookings/elements/DownloadBillingWithDatesComponent.vue @@ -109,7 +109,8 @@ export default { successHandler(response) { if(window.LARAVEL_VAPOR_ENABLED){ if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } } }, diff --git a/resources/assets/vue/components/bookings/elements/DownloadSupplierWhiteFormComponent.vue b/resources/assets/vue/components/bookings/elements/DownloadSupplierWhiteFormComponent.vue index b12e98ba..732770e5 100644 --- a/resources/assets/vue/components/bookings/elements/DownloadSupplierWhiteFormComponent.vue +++ b/resources/assets/vue/components/bookings/elements/DownloadSupplierWhiteFormComponent.vue @@ -93,7 +93,8 @@ export default { this.returnData = null; if(window.LARAVEL_VAPOR_ENABLED){ if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } } } diff --git a/resources/assets/vue/components/bookings/elements/DownloadTransactionsReportComponent.vue b/resources/assets/vue/components/bookings/elements/DownloadTransactionsReportComponent.vue new file mode 100644 index 00000000..a5b78afe --- /dev/null +++ b/resources/assets/vue/components/bookings/elements/DownloadTransactionsReportComponent.vue @@ -0,0 +1,110 @@ + + + + + + diff --git a/resources/assets/vue/components/bookings/elements/ShowWhiteFormTransactionsComponent.vue b/resources/assets/vue/components/bookings/elements/ShowWhiteFormTransactionsComponent.vue new file mode 100644 index 00000000..a163dab1 --- /dev/null +++ b/resources/assets/vue/components/bookings/elements/ShowWhiteFormTransactionsComponent.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/resources/assets/vue/components/bookings/elements/UploadDebtorExcelComponent.vue b/resources/assets/vue/components/bookings/elements/UploadDebtorExcelComponent.vue index 85db0263..c999b81a 100644 --- a/resources/assets/vue/components/bookings/elements/UploadDebtorExcelComponent.vue +++ b/resources/assets/vue/components/bookings/elements/UploadDebtorExcelComponent.vue @@ -81,7 +81,8 @@ response.json().then(response => { if(!success){return;} if (response.src) { - window.location.href = response.src; + // window.location.href = response.src; + window.open(response.src, '_blank'); } }); } diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 5a03999c..9208852c 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -614,7 +614,7 @@ bookingId: this.data.id }, isEditRecipientBankDetailsCollapsed: false, - isAnyPaymentRecipientBankEdited: this.data.payment_history.some(payment => payment.bank !== null), + isAnyPaymentRecipientBankEdited: this.data.payment_history.some(payment => payment.bank_recipient_edited !== null && payment.bank_recipient_edited), } }, validations () { diff --git a/resources/assets/vue/components/bookings/forms/EditPaymentRecipientBankDetailsComponent.vue b/resources/assets/vue/components/bookings/forms/EditPaymentRecipientBankDetailsComponent.vue index 857548cf..4a9b81b6 100644 --- a/resources/assets/vue/components/bookings/forms/EditPaymentRecipientBankDetailsComponent.vue +++ b/resources/assets/vue/components/bookings/forms/EditPaymentRecipientBankDetailsComponent.vue @@ -18,8 +18,8 @@
- - + +
- - + +
+
-
+ +
@@ -60,6 +61,14 @@
+
+
+ +
+
+
+
+
diff --git a/routes/web.php b/routes/web.php index 90711eaf..3e8f3d64 100644 --- a/routes/web.php +++ b/routes/web.php @@ -291,6 +291,7 @@ Route::get('billplz/bills/{bill_no}', function($bill_no){ Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export')->name('customers.export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions')->name('transactions.export'); +Route::get('/export/transactions/v2/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@v2transactions')->name('transactions.v2.export'); 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');