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 @@
+
+ (default: last 1 month) (default: last 2 weeks)