From 8b120e60f4b52d698c0d5bdc023f1a8bb77a551e Mon Sep 17 00:00:00 2001 From: Annika Date: Wed, 13 Jul 2022 16:07:44 -0600 Subject: [PATCH] fixed bug where transactions couldn't be created without category --- budgit/server/services/CategoriesService.js | 1 + budgit/server/services/TransactionsService.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/budgit/server/services/CategoriesService.js b/budgit/server/services/CategoriesService.js index 56569f0..f4622d1 100644 --- a/budgit/server/services/CategoriesService.js +++ b/budgit/server/services/CategoriesService.js @@ -51,6 +51,7 @@ class CategoriesService { if (!category) { throw new BadRequest('category does not exist') } + // TODO this needs to reallocate all transactions under this category to unassigned category.remove() return category } diff --git a/budgit/server/services/TransactionsService.js b/budgit/server/services/TransactionsService.js index 1c14064..8c8c615 100644 --- a/budgit/server/services/TransactionsService.js +++ b/budgit/server/services/TransactionsService.js @@ -4,6 +4,9 @@ import { logger } from '../utils/Logger' class TransactionsService { async create(newTransaction) { + if (newTransaction.categoryId == '') { + newTransaction.categoryId = null + } const dbTransaction = await dbContext.Transactions.create(newTransaction) if (!dbTransaction) { throw new BadRequest("transaction does not exist")