diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php
new file mode 100644
index 00000000..745539f5
--- /dev/null
+++ b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php
@@ -0,0 +1,107 @@
+request = $request;
+ }
+
+ public function headings(): array
+ {
+ return [
+ 'Date',
+ 'Description',
+ 'Incoming',
+ 'Outgoing',
+ 'Balance',
+ ];
+ }
+
+ /**
+ * @return \Illuminate\Support\Collection|mixed
+ */
+ public function query()
+ {
+ $company = Company::where('reference', $this->request->route('marking'))->first();
+ $transactions = $company->wallets()->first()->transactions()->whereIn('transactions.status', [2, 3])->orderBy('id');
+ // dd($transactions->get()->toArray());
+
+ return $transactions;
+ }
+
+ /**
+ * @param Transaction $transaction
+ *
+ * @return array
+ */
+ public function map($transaction): array
+ {
+ // dd($transaction);
+
+ $decimals = $this->request->route('is_precise') == 'true' ? 5 : 2;
+
+ $description = '';
+ switch ((int) $transaction->type) {
+ case 5:
+ $description = (float) $transaction->amount . ' Credit Top up';
+ break;
+ case 9:
+ $description = 'Credit Voucher for ' . $transaction->payment_reference;
+ break;
+ case 1:
+ $booking = Transaction::where('payment_reference', $transaction->bill_no)->first()->owner;
+
+ if (!$booking) {
+ $description = 'Payment for unknown booking, please contact tech support.';
+ break;
+ }
+
+ $marking = $booking->marking;
+ $description = 'Payment For booking refs' . $marking;
+ break;
+ case 11:
+ $description = 'Debit Voucher for ' . $transaction->payment_reference;
+ break;
+ }
+
+ $incoming = $outgoing = '';
+
+ if (in_array($transaction->type, [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE])) {
+ $incoming = number_format($transaction->amount, $decimals, '.', ',');
+ $this->runningBalance += $transaction->amount;
+ }
+
+ if (in_array($transaction->type, [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE])) {
+ $outgoing = number_format($transaction->amount, $decimals, '.', ',');
+ $this->runningBalance -= $transaction->amount;
+ }
+
+ return [
+ Carbon::parse($transaction->created_at)->format('d-m-Y h:i:s A'),
+ $description,
+ $incoming,
+ $outgoing,
+ number_format($this->runningBalance, $decimals, '.', ',')
+ ];
+ }
+}
diff --git a/app/Http/Controllers/Exports/ExportCustomersWalletTransactionToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersWalletTransactionToExcelController.php
new file mode 100644
index 00000000..c4457565
--- /dev/null
+++ b/app/Http/Controllers/Exports/ExportCustomersWalletTransactionToExcelController.php
@@ -0,0 +1,32 @@
+headers->set('Authorization', 'Bearer ' . $token);
+ }
+
+ public function export(Request $request)
+ {
+ $exportsTransactions = new ExportsCustomersWalletTransactionHistory($request);
+ $filename = $request->route('marking') . '-wallet-' . ($request->route('is_precise') == 'true' ? 'precise-' : '') . 'transaction-history.xls';
+ $response = $exportsTransactions->download($filename, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
+ ob_end_clean();
+ return $response;
+ }
+}
diff --git a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue
index 026a76c5..d1448193 100644
--- a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue
+++ b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue
@@ -6,7 +6,7 @@
-
Transaction History
+ Account Statement - Transaction History
diff --git a/resources/assets/vue/components/wallets/elements/CustomerTransactionComponent.vue b/resources/assets/vue/components/wallets/elements/CustomerTransactionComponent.vue
new file mode 100644
index 00000000..4d25f91b
--- /dev/null
+++ b/resources/assets/vue/components/wallets/elements/CustomerTransactionComponent.vue
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
Date
+
Description
+
Incoming
+
Outgoing
+
Balance
+
+
+
+
{{item.created_at}}
+
+
{{[5, 9].includes(parseFloat(item.type)) ? formatValue(item.amount) : ''}}
+
{{[1, 11].includes(parseFloat(item.type)) ? '- ' + (formatValue(item.amount)) : ''}}
+
{{remainingBalance(index)}}
+
+
+
+
+
+
+
+
+
+
+
+
+ There is no results found, Try adjusting your filters to find what you are looking for.
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/assets/vue/components/wallets/elements/CustomerTransactionPreciseSectionComponent.vue b/resources/assets/vue/components/wallets/elements/CustomerTransactionPreciseSectionComponent.vue
deleted file mode 100644
index 85868a2b..00000000
--- a/resources/assets/vue/components/wallets/elements/CustomerTransactionPreciseSectionComponent.vue
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
-
-
-
-
-
-
-
Transaction History
-
-
-
-
-
-
Date
-
Description
-
Incoming
-
Outgoing
-
Balance
-
-
-
-
{{ item.created_at }}
-
-
- {{ [5, 9].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100000) / 100000).toLocaleString('en-US', { minimumFractionDigits: 5, maximumFractionDigits: 5 }) : '' }}
-
-
- {{ [1, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100000) / 100000).toLocaleString('en-US', { minimumFractionDigits: 5, maximumFractionDigits: 5 }) : '' }}
-
-
{{ remainingBalance(index) }}
-
-
-
-
-
-
-
-
-
-
-
-
Nothing To Show
- Here
-
-
-
-
- There
- is no results found, Try adjusting your filters to find what you are looking
- for.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Nothing
- To Show Here
-
-
-
-
- There is no results found, Try adjusting
- your filters to find what you are looking for.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue b/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue
index fcfba752..706bc95a 100644
--- a/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue
+++ b/resources/assets/vue/components/wallets/elements/CustomerTransactionSectionComponent.vue
@@ -6,49 +6,20 @@
-
Transaction History
+ Wallet Transaction History
-
+
-
-
Date
-
Description
-
Incoming
-
Outgoing
-
Balance
-
-
-
-
{{item.created_at}}
-
-
{{[5, 9].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}
-
{{[1, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}
-
{{remainingBalance(index)}}
-
+
{{ showingPreciseAmount ? 'Showing Precise Wallet Transaction' : 'Show Precise Wallet Transaction'}}
+
{{ showingPreciseAmount ? 'Download Precise Transaction' : 'Download Transaction'}}
-
-
-
-
-
-
-
-
-
- There is no results found, Try adjusting your filters to find what you are looking for.
-
-
-
-
-
+
+
+
+
+
@@ -106,6 +77,7 @@ export default {
section: 'customerTransactionSection',
isLoading: true,
company: null,
+ showingPreciseAmount: false,
attention: false
}
},
@@ -129,19 +101,6 @@ export default {
this.isLoading = true;
this.submit(route('api.company.show', this.id), 'get', this.section, false, false)
},
- remainingBalance(index) {
- let tempBalance = 0;
-
- if(this.company.wallet){
- let transactions = this.company.wallet.transactions.slice().reverse();
- transactions.slice(0, transactions.length - index).map(function(transaction) {
- [1, 11].includes(transaction.type) ? tempBalance -= (transaction.amount) : tempBalance += (transaction.amount);
- return tempBalance
- }, 0);
- }
-
- return (Math.round((tempBalance + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
- },
successHandler(response){
this.isLoading = false;
this.company = response.payload.data;
diff --git a/routes/web.php b/routes/web.php
index 7167410a..08d6bec7 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -235,10 +235,7 @@ Route::get('/wallet/{marking}/details', function ($marking) {
return view('pages.wallet.index', ['id' => $id]);
})->name('wallet.details');
-Route::get('/wallet/{marking}/details-precise', function ($marking) {
- $id = \App\Models\Company::where('reference', '=', $marking)->first()->id;
- return view('pages.wallet.precise', ['id' => $id]);
-})->name('wallet.details-precise');
+Route::get('/wallet/{marking}/{is_precise}/export', 'Exports\ExportCustomersWalletTransactionToExcelController@export')->name('wallet.details-export');
Route::get('/wallets', function () {
return view('pages.wallet.wallets');