Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117908806
D4809.1775393987.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
D4809.1775393987.diff
View Options
diff --git a/src/app/Http/Controllers/API/V4/WalletsController.php b/src/app/Http/Controllers/API/V4/WalletsController.php
--- a/src/app/Http/Controllers/API/V4/WalletsController.php
+++ b/src/app/Http/Controllers/API/V4/WalletsController.php
@@ -115,21 +115,42 @@
return $this->errorResponse(403);
}
+ $pageSize = 10;
+ $page = intval(request()->input('page')) ?: 1;
+ $hasMore = false;
+
$result = $wallet->payments()
- ->selectRaw('distinct date_format(updated_at, "%Y-%m") as ident')
+ ->selectRaw('date_format(updated_at, "%Y-%m") as ident, sum(amount) as total')
->where('status', Payment::STATUS_PAID)
->where('amount', '<>', 0)
->orderBy('ident', 'desc')
+ ->groupBy('ident')
+ ->limit($pageSize + 1)
+ ->offset($pageSize * ($page - 1))
->get()
- ->whereNotIn('ident', [date('Y-m')]) // exclude current month
- ->pluck('ident');
+ ->whereNotIn('ident', [date('Y-m')]); // exclude current month
+
+
+ if (count($result) > $pageSize) {
+ $result->pop();
+ $hasMore = true;
+ }
+
+ $result = $result->map(function ($item) use ($wallet) {
+ $entry = [
+ 'period' => $item->ident,
+ 'amount' => $item->total,
+ 'currency' => $wallet->currency
+ ];
+ return $entry;
+ });
return response()->json([
'status' => 'success',
'list' => $result,
'count' => count($result),
- 'hasMore' => false,
- 'page' => 1,
+ 'hasMore' => $hasMore,
+ 'page' => $page,
]);
}
diff --git a/src/resources/vue/Wallet.vue b/src/resources/vue/Wallet.vue
--- a/src/resources/vue/Wallet.vue
+++ b/src/resources/vue/Wallet.vue
@@ -46,20 +46,7 @@
<div class="tab-content">
<div class="tab-pane active" id="receipts" role="tabpanel" aria-labelledby="tab-receipts">
<div class="card-body">
- <div class="card-text">
- <p v-if="receipts.length">
- {{ $t('wallet.receipts-hint') }}
- </p>
- <div v-if="receipts.length" class="input-group">
- <select id="receipt-id" class="form-control">
- <option v-for="(receipt, index) in receipts" :key="index" :value="receipt">{{ receipt }}</option>
- </select>
- <btn class="btn-secondary" @click="receiptDownload" icon="download">{{ $t('btn.download') }}</btn>
- </div>
- <p v-if="!receipts.length">
- {{ $t('wallet.receipts-none') }}
- </p>
- </div>
+ <receipt-list v-if="walletId && loadReceipts" class="card-text" :wallet-id="walletId"></receipt-list>
</div>
</div>
<div class="tab-pane" id="history" role="tabpanel" aria-labelledby="tab-history">
@@ -154,6 +141,7 @@
import ModalDialog from './Widgets/ModalDialog'
import TransactionLog from './Widgets/TransactionLog'
import PaymentLog from './Widgets/PaymentLog'
+ import ReceiptList from './Widgets/ReceiptList'
import { downloadFile, paymentCheckout } from '../js/utils'
import { library } from '@fortawesome/fontawesome-svg-core'
@@ -170,7 +158,8 @@
components: {
ModalDialog,
TransactionLog,
- PaymentLog
+ PaymentLog,
+ ReceiptList
},
data() {
return {
@@ -182,6 +171,7 @@
receipts: [],
loadTransactions: false,
loadPayments: false,
+ loadReceipts: true,
showPendingPayments: false,
wallet: {},
walletId: null,
@@ -242,6 +232,7 @@
this.$refs.tabs.clickHandler('history', () => { this.loadTransactions = true })
this.$refs.tabs.clickHandler('payments', () => { this.loadPayments = true })
+ this.$refs.tabs.clickHandler('receipts', () => { this.loadReceipts = true })
},
methods: {
loadMandate() {
@@ -375,10 +366,6 @@
this.$refs.paymentDialog.show()
},
- receiptDownload() {
- const receipt = $('#receipt-id').val()
- downloadFile('/api/v4/wallets/' + this.walletId + '/receipts/' + receipt)
- }
}
}
</script>
diff --git a/src/resources/vue/Widgets/ReceiptList.vue b/src/resources/vue/Widgets/ReceiptList.vue
new file mode 100644
--- /dev/null
+++ b/src/resources/vue/Widgets/ReceiptList.vue
@@ -0,0 +1,69 @@
+<template>
+ <div>
+ <table class="table table-sm m-0 receipts">
+ <thead>
+ <tr>
+ <th scope="col">{{ $t('form.date') }}</th>
+ <th scope="col" v-if="isAdmin">{{ $t('form.user') }}</th>
+ <th scope="col" class="price">{{ $t('form.amount') }}</th>
+ <th scope="col"></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr v-for="receipt in receipts" :id="'log' + receipt.id" :key="receipt.id">
+ <td class="datetime">{{ receipt.period }}</td>
+ <td class="email" v-if="isAdmin">{{ receipt.user }}</td>
+ <td :class="'price ' + className(receipt)">{{ amount(receipt) }}</td>
+ <td class="selection">
+ <btn class="btn-secondary" @click="receiptDownload(receipt.period)" icon="download">{{ $t('btn.download') }}</btn>
+
+ <!--btn v-if="transaction.hasDetails" class="btn-lg btn-link btn-action" icon="circle-info"
+ :title="$t('form.details')"
+ @click="loadTransaction(transaction.id)"
+ ></btn-->
+ </td>
+ </tr>
+ </tbody>
+ <list-foot :text="$t('wallet.receipts-none')" :colspan="isAdmin ? 5 : 4"></list-foot>
+ </table>
+ <list-more v-if="hasMore" :on-click="loadMore"></list-more>
+ </div>
+</template>
+
+
+<script>
+ import ListTools from './ListTools'
+ import { downloadFile } from '../../js/utils'
+
+ export default {
+ mixins: [ ListTools ],
+ props: {
+ walletId: { type: String, default: null },
+ isAdmin: { type: Boolean, default: false },
+ },
+ data() {
+ return {
+ receipts: []
+ }
+ },
+ mounted() {
+ this.loadMore({ reset: true })
+ },
+ methods: {
+ loadMore(params) {
+ if (this.walletId) {
+ this.listSearch('receipts', '/api/v4/wallets/' + this.walletId + '/receipts', params)
+ }
+ },
+ amount(receipt) {
+ return this.$root.price(receipt.amount, receipt.currency)
+ },
+ className(receipt) {
+ return receipt.amount < 0 ? 'text-danger' : 'text-success';
+ },
+ receiptDownload(period) {
+ downloadFile('/api/v4/wallets/' + this.walletId + '/receipts/' + period)
+ }
+ }
+ }
+</script>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 12:59 PM (8 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18833501
Default Alt Text
D4809.1775393987.diff (7 KB)
Attached To
Mode
D4809: Turn the Receipt download into a ReceiptList
Attached
Detach File
Event Timeline