diff --git a/src/views/AddEntryView.vue b/src/views/AddEntryView.vue
index d39e896..da42c5e 100644
--- a/src/views/AddEntryView.vue
+++ b/src/views/AddEntryView.vue
@@ -3,7 +3,7 @@ import { computed, reactive, ref, watch } from 'vue'
import {
DEFAULT_TRANSACTION_CATEGORY,
TRANSACTION_CATEGORIES,
- getCategoryLabel,
+ getCategoryMeta,
} from '../config/transactionCategories.js'
import { useTransactionStore } from '../stores/transactions'
import { useUiStore } from '../stores/ui'
@@ -19,7 +19,11 @@ const dragStartY = ref(0)
const dragging = ref(false)
const dragOffset = ref(0)
-const categories = TRANSACTION_CATEGORIES
+const categories = computed(() =>
+ TRANSACTION_CATEGORIES.filter((category) =>
+ form.type === 'income' ? ['Income', 'Uncategorized'].includes(category.value) : category.value !== 'Income',
+ ),
+)
const toDatetimeLocal = (value) => {
const date = value ? new Date(value) : new Date()
@@ -65,6 +69,19 @@ const hydrateForm = () => {
watch(editingId, hydrateForm, { immediate: true })
+watch(
+ () => form.type,
+ (nextType) => {
+ if (nextType === 'income' && form.category !== 'Income') {
+ form.category = 'Income'
+ return
+ }
+ if (nextType === 'expense' && form.category === 'Income') {
+ form.category = DEFAULT_TRANSACTION_CATEGORY
+ }
+ },
+)
+
const closePanel = () => {
uiStore.closeAddEntry()
}
@@ -181,9 +198,9 @@ const sheetStyle = computed(() => {
-
+
支出
-
-
-
账本样本
-
-
聊天时会带上最近 80 条记录摘要
-
-
-
AI 状态
-
-
- {{ aiReady ? '使用设置页里的 DeepSeek Key 直接调用。' : '先去设置页填写 DeepSeek API Key。' }}
-
-
-
-
-
-
-
-
当前还没有账本记录。聊天功能可以使用,但回答只会提示你先开始记账。
+
+ 先去设置页填写 DeepSeek API Key,这里才能真正发送提问。
+
+
-
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index 5a40df5..9510113 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -12,6 +12,8 @@ import {
getEntryTypeLabel,
getTransferSummary,
isStoredValueAccountType,
+ shouldCountAsExpense,
+ shouldCountAsIncome,
} from '../config/ledger.js'
import { getCategoryLabel, getCategoryMeta } from '../config/transactionCategories.js'
import { bootstrapApp } from '../services/appBootstrap.js'
@@ -104,6 +106,28 @@ const periodExpense = computed(() => {
}, 0)
})
+const currentMonthIncome = computed(() =>
+ (sortedTransactions.value || []).reduce((sum, tx) => {
+ const date = new Date(tx.date)
+ const now = new Date()
+ if (date.getFullYear() !== now.getFullYear() || date.getMonth() !== now.getMonth()) return sum
+ return shouldCountAsIncome(tx) ? sum + tx.amount : sum
+ }, 0),
+)
+
+const currentMonthExpense = computed(() =>
+ Math.abs(
+ (sortedTransactions.value || []).reduce((sum, tx) => {
+ const date = new Date(tx.date)
+ const now = new Date()
+ if (date.getFullYear() !== now.getFullYear() || date.getMonth() !== now.getMonth()) return sum
+ return shouldCountAsExpense(tx) ? sum + tx.amount : sum
+ }, 0),
+ ),
+)
+
+const currentMonthNet = computed(() => currentMonthIncome.value - currentMonthExpense.value)
+
const budgetUsage = computed(() => {
const expense = Math.abs(periodExpense.value || 0)
const budget = monthlyBudget.value || 0
@@ -111,7 +135,6 @@ const budgetUsage = computed(() => {
return Math.min(expense / budget, 1)
})
-const balance = computed(() => (totalIncome.value || 0) + (totalExpense.value || 0))
const remainingBudget = computed(() =>
Math.max((monthlyBudget.value || 0) - Math.abs(periodExpense.value || 0), 0),
)
@@ -191,10 +214,6 @@ const goList = () => {
router.push({ name: 'list' })
}
-const goAnalysis = () => {
- router.push({ name: 'analysis' })
-}
-
const openTransactionDetail = (tx) => {
if (!tx?.id) return
uiStore.openAddEntry(tx.id)
@@ -223,38 +242,37 @@ const openTransactionDetail = (tx) => {
-
+
-
当前结余
-
+
+
本月净结余
+
仅统计本月已入账的收入和支出
+
+
本月口径
-
-
-
+
+
收入
-
{{ formatCurrency(totalIncome) }}
+
{{ formatCurrency(currentMonthIncome) }}
-
+
支出
-
{{ formatCurrency(Math.abs(totalExpense)) }}
+
{{ formatCurrency(currentMonthExpense) }}
@@ -437,22 +455,5 @@ const openTransactionDetail = (tx) => {
-
-
-
-
-
-
-
AI 财务顾问
-
现在可直接对话分析账本,并查看自动分类建议和预算提醒。
-
-
diff --git a/src/views/ListView.vue b/src/views/ListView.vue
index a18be92..110a19e 100644
--- a/src/views/ListView.vue
+++ b/src/views/ListView.vue
@@ -117,7 +117,7 @@ const hasData = computed(() => groupedTransactions.value.length > 0)
@@ -188,25 +188,25 @@ const hasData = computed(() => groupedTransactions.value.length > 0)
-
- {{ resolveLedgerBadge(item).label }}
+
+ {{ resolveLedgerBadge(item).label }}
- {{ resolveAiBadge(item).label }}
+ {{ resolveAiBadge(item).label }}
diff --git a/src/views/SettingsView.vue b/src/views/SettingsView.vue
index 7fd312a..dd52335 100644
--- a/src/views/SettingsView.vue
+++ b/src/views/SettingsView.vue
@@ -28,7 +28,7 @@ const notificationCaptureEnabled = computed({
get: () => settingsStore.notificationCaptureEnabled,
set: (value) => settingsStore.setNotificationCaptureEnabled(value),
})
-
+
const aiAutoCategoryEnabled = computed({
get: () => settingsStore.aiAutoCategoryEnabled,
set: (value) => settingsStore.setAiAutoCategoryEnabled(value),