Open source personal finance application
fix(convex): prevent creating non-Transfer trns with categoryId 'transfer'
Ilya Komichev9328bc7ebd79
diff --git a/convex/trns.ts b/convex/trns.tsindex 348b922f..76d4469e 100644--- a/convex/trns.ts+++ b/convex/trns.ts@@ -31,8 +31,10 @@ async function validateTrnFields(ctx: MutationCtx, args: Record<string, any>, usthrow new Error('Wallet is required')if (!args.categoryId)throw new Error('Category is required')+ if (args.categoryId === 'transfer')+ throw new Error('categoryId "transfer" is only allowed for Transfer type')await getOwnEntity(ctx, args.walletId as Id<'wallets'>, userId, 'Wallet not found')- if (args.categoryId !== 'transfer' && args.categoryId !== 'adjustment')+ if (args.categoryId !== 'adjustment')await getOwnEntity(ctx, args.categoryId as Id<'categories'>, userId, 'Category not found')}}