Files
firefly-iii/frontend/src/components/transactions/TransactionListSmall.vue

82 lines
3.3 KiB
Vue
Raw Normal View History

2020-07-03 05:59:36 +02:00
<!--
- TransactionListSmall.vue
- Copyright (c) 2020 james@firefly-iii.org
-
- This file is part of Firefly III (https://github.com/firefly-iii).
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
2020-06-22 18:03:57 +02:00
<template>
2020-07-12 17:30:24 +02:00
<table class="table table-striped table-sm">
2020-07-02 20:23:45 +02:00
<caption style="display:none;">{{ $t('firefly.transaction_table_description') }}</caption>
2020-06-27 17:33:18 +02:00
<thead>
<tr>
2020-07-02 20:23:45 +02:00
<th class="text-left">{{ $t('firefly.description') }}</th>
<th class="text-right">{{ $t('firefly.amount') }}</th>
2020-06-27 17:33:18 +02:00
</tr>
</thead>
<tbody>
2020-06-29 08:04:38 +02:00
<tr v-for="transaction in this.transactions">
2020-06-22 18:03:57 +02:00
<td>
2020-06-29 08:04:38 +02:00
<a :href="'transactions/show/' + transaction.id " :title="transaction.date">
2020-06-22 18:03:57 +02:00
<span v-if="transaction.attributes.transactions.length > 1">{{ transaction.attributes.group_title }}</span>
<span v-if="1===transaction.attributes.transactions.length">{{ transaction.attributes.transactions[0].description }}</span>
</a>
</td>
<td style="text-align:right;">
<span v-for="tr in transaction.attributes.transactions">
<span v-if="'withdrawal' === tr.type" class="text-danger">
{{ Intl.NumberFormat('en-US', {style: 'currency', currency: tr.currency_code}).format(tr.amount * -1)}}<br>
</span>
<span v-if="'deposit' === tr.type" class="text-success">
{{ Intl.NumberFormat('en-US', {style: 'currency', currency: tr.currency_code}).format(tr.amount)}}<br>
</span>
2020-06-29 08:04:38 +02:00
<span v-if="'transfer' === tr.type && tr.source_id === account_id" class="text-info">
{{ Intl.NumberFormat('en-US', {style: 'currency', currency: tr.currency_code}).format(tr.amount * -1)}}<br>
</span>
<span v-if="'transfer' === tr.type && tr.destination_id === account_id" class="text-info">
{{ Intl.NumberFormat('en-US', {style: 'currency', currency: tr.currency_code}).format(tr.amount)}}<br>
</span>
2020-06-22 18:03:57 +02:00
</span>
</td>
</tr>
2020-06-27 17:33:18 +02:00
</tbody>
2020-06-22 18:03:57 +02:00
</table>
</template>
<script>
export default {
name: "TransactionListSmall",
props: {
transactions: {
type: Array,
default: function () {
return [];
}
},
2020-06-29 08:04:38 +02:00
account_id: {
type: Number,
default: function() {
return 0;
}
},
2020-06-22 18:03:57 +02:00
}
}
</script>
<style scoped>
</style>