From 7616d1256d237719e6fb195b4a3ce443752c3263 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sat, 16 Nov 2024 21:35:39 +1100 Subject: [PATCH] Implement journal view --- src/main.ts | 1 + src/pages/GeneralLedgerView.vue | 19 ++-- src/pages/HomeView.vue | 2 +- src/pages/JournalView.vue | 157 ++++++++++++++++++++++++++++++++ 4 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 src/pages/JournalView.vue diff --git a/src/main.ts b/src/main.ts index a35a94a..01a598f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,6 +30,7 @@ async function initApp() { const routes = [ { path: '/', name: 'index', component: () => import('./pages/HomeView.vue') }, { path: '/general-ledger', name: 'general-ledger', component: () => import('./pages/GeneralLedgerView.vue') }, + { path: '/journal', name: 'journal', component: () => import('./pages/JournalView.vue') }, { path: '/transactions/:account', name: 'transactions', component: () => import('./pages/TransactionsView.vue') }, { path: '/trial-balance', name: 'trial-balance', component: () => import('./pages/TrialBalanceView.vue') }, ]; diff --git a/src/pages/GeneralLedgerView.vue b/src/pages/GeneralLedgerView.vue index 4d07e74..ca72b82 100644 --- a/src/pages/GeneralLedgerView.vue +++ b/src/pages/GeneralLedgerView.vue @@ -22,8 +22,8 @@
- - + +
@@ -44,7 +44,7 @@ - Loading data… + Loading data… @@ -56,7 +56,7 @@ import dayjs from 'dayjs'; - import { onUnmounted, ref } from 'vue'; + import { onUnmounted, ref, watch } from 'vue'; import { asCost } from '../amounts.ts'; import { JoinedTransactionPosting, Transaction, db, joinedToTransactions } from '../db.ts'; @@ -64,7 +64,7 @@ const commodityDetail = ref(false); - let transactions: Transaction[] = []; + const transactions = ref([] as Transaction[]); let clusterize: Clusterize | null = null; async function load() { @@ -77,15 +77,13 @@ ORDER BY dt DESC, transaction_id DESC, postings.id` ); - transactions = joinedToTransactions(joinedTransactionPostings); - - renderTable(); + transactions.value = joinedToTransactions(joinedTransactionPostings); } function renderTable() { const rows = []; - for (const transaction of transactions) { + for (const transaction of transactions.value) { rows.push( ` ${ dayjs(transaction.dt).format('YYYY-MM-DD') } @@ -140,6 +138,9 @@ } } + watch(commodityDetail, renderTable); + watch(transactions, renderTable); + load(); onUnmounted(() => { diff --git a/src/pages/HomeView.vue b/src/pages/HomeView.vue index a4dffd9..0ec2d57 100644 --- a/src/pages/HomeView.vue +++ b/src/pages/HomeView.vue @@ -21,7 +21,7 @@

Data sources

    - +
  • Journal
  • diff --git a/src/pages/JournalView.vue b/src/pages/JournalView.vue new file mode 100644 index 0000000..4ef60fd --- /dev/null +++ b/src/pages/JournalView.vue @@ -0,0 +1,157 @@ + + + + +