Skip to content

Open source personal finance application

fix: computeTrnItem returns null for transfers and adjustments

Ilya Komichevf7137c211022
diff --git a/app/components/trns/useTrnsStore.ts b/app/components/trns/useTrnsStore.ts
index 28d2e95e..4795101f 100644
--- a/app/components/trns/useTrnsStore.ts
+++ b/app/components/trns/useTrnsStore.ts
@@ -360,14 +360,21 @@ export const useTrnsStore = defineStore('trns', () => {
if (!trn)
return null
- // Category
- const category = categoriesStore.items[trn.categoryId]
- if (!category)
- return null
-
- // Parent category
- let categoryParent
- if (category.parentId) {
+ // Category (synthetic for special categoryIds)
+ let category = categoriesStore.items[trn.categoryId]
+ let categoryParent: typeof category | undefined
+
+ if (!category) {
+ if (trn.categoryId === 'transfer' || trn.categoryId === 'adjustment') {
+ category = trn.categoryId === 'transfer'
+ ? { color: 'var(--text-2)', icon: 'lucide:arrow-left-right', name: 'Transfer', parentId: 0, showInLastUsed: false, showInQuickSelector: false }
+ : { color: 'var(--text-2)', icon: 'lucide:scale', name: 'Adjustment', parentId: 0, showInLastUsed: false, showInQuickSelector: false }
+ }
+ else {
+ return null
+ }
+ }
+ else if (category.parentId) {
categoryParent = categoriesStore.items[category.parentId]
if (!categoryParent)
return null