fixed bug where transactions couldn't be created without category

This commit is contained in:
Annika
2022-07-13 16:07:44 -06:00
parent 57b247767d
commit 8b120e60f4
2 changed files with 4 additions and 0 deletions
@@ -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
}
@@ -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")