Add category-activity transaction view

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2024-03-10 12:52:53 +01:00
parent c93b2ade07
commit 4e255c2740
Signed by: luzifer
SSH key fingerprint: SHA256:/xtE5lCgiRDQr8SLxHMS92ZBlACmATUmF1crK16Ks4E
3 changed files with 33 additions and 3 deletions

View file

@ -58,6 +58,7 @@
<button <button
v-shortkey.once="['ctrl', 'alt', 'n']" v-shortkey.once="['ctrl', 'alt', 'n']"
class="btn btn-primary" class="btn btn-primary"
:disabled="accountIsCategory"
@click="showAddTransaction = !showAddTransaction" @click="showAddTransaction = !showAddTransaction"
@shortkey="showAddTransaction = !showAddTransaction" @shortkey="showAddTransaction = !showAddTransaction"
> >
@ -66,6 +67,7 @@
</button> </button>
<button <button
class="btn btn-primary" class="btn btn-primary"
:disabled="accountIsCategory"
data-bs-toggle="modal" data-bs-toggle="modal"
data-bs-target="#transferMoneyModal" data-bs-target="#transferMoneyModal"
> >
@ -75,6 +77,7 @@
<button <button
class="btn btn-success" class="btn btn-success"
:disabled="accountIsCategory"
@click="markAccountReconciled" @click="markAccountReconciled"
> >
<i class="fas fa-fw fa-square-check mr-1" /> <i class="fas fa-fw fa-square-check mr-1" />
@ -150,6 +153,9 @@
<th class="minimized-column"> <th class="minimized-column">
Date Date
</th> </th>
<th v-if="accountIsCategory">
Account
</th>
<th>Payee</th> <th>Payee</th>
<th v-if="account.type !== 'tracking'"> <th v-if="account.type !== 'tracking'">
Category Category
@ -177,7 +183,7 @@
> >
<tr <tr
v-if="tx.id !== editedTxId" v-if="tx.id !== editedTxId"
:key="tx.id" :key="`display-${tx.id}`"
@dblclick="editTx(tx.id)" @dblclick="editTx(tx.id)"
> >
<td> <td>
@ -189,6 +195,9 @@
<td class="minimized-column"> <td class="minimized-column">
{{ new Date(tx.time).toLocaleDateString() }} {{ new Date(tx.time).toLocaleDateString() }}
</td> </td>
<td v-if="accountIsCategory">
{{ accountIdToName[tx.account] }}
</td>
<td>{{ tx.payee }}</td> <td>{{ tx.payee }}</td>
<td v-if="account.type !== 'tracking'"> <td v-if="account.type !== 'tracking'">
{{ accountIdToName[tx.category] }} {{ accountIdToName[tx.category] }}
@ -216,7 +225,7 @@
</tr> </tr>
<tx-editor <tx-editor
v-else v-else
:key="tx.id" :key="`editor-${tx.id}`"
:account="account" :account="account"
:accounts="accounts" :accounts="accounts"
:edit="tx" :edit="tx"
@ -391,6 +400,10 @@ export default {
return Object.fromEntries(this.accounts.map(acc => [acc.id, acc.name])) return Object.fromEntries(this.accounts.map(acc => [acc.id, acc.name]))
}, },
accountIsCategory() {
return this.account.type === 'category'
},
accountTypes() { accountTypes() {
return Object.fromEntries(this.accounts.map(acc => [acc.id, acc.type])) return Object.fromEntries(this.accounts.map(acc => [acc.id, acc.type]))
}, },

View file

@ -63,7 +63,13 @@
{{ formatNumber(allocatedByCategory[cat.id] || 0) }} {{ formatNumber(allocatedByCategory[cat.id] || 0) }}
</td> </td>
<td :class="classFromNumber(activityByCategory[cat.id] || 0, ['text-end'])"> <td :class="classFromNumber(activityByCategory[cat.id] || 0, ['text-end'])">
{{ formatNumber(activityByCategory[cat.id] || 0) }} <router-link
class="text-white text-decoration-none"
:to="{ name: 'account-transactions', params: { accountId: cat.id }}"
title="List Transactions"
>
{{ formatNumber(activityByCategory[cat.id] || 0) }}
</router-link>
</td> </td>
<td class="text-end"> <td class="text-end">
<a <a

View file

@ -11,6 +11,9 @@
@keyup.enter="$refs.payee.focus()" @keyup.enter="$refs.payee.focus()"
> >
</td> </td>
<td v-if="accountIsCategory">
{{ accountIdToName[edit.account] }}
</td>
<td> <td>
<input <input
ref="payee" ref="payee"
@ -75,6 +78,14 @@ import { responseToJSON } from '../helpers'
export default { export default {
computed: { computed: {
accountIdToName() {
return Object.fromEntries(this.accounts.map(acc => [acc.id, acc.name]))
},
accountIsCategory() {
return this.account.type === 'category'
},
categories() { categories() {
const cats = this.accounts.filter(acc => acc.type === 'category') const cats = this.accounts.filter(acc => acc.type === 'category')
cats.sort((a, b) => a.name.localeCompare(b.name)) cats.sort((a, b) => a.name.localeCompare(b.name))