fixed bug where transactions couldn't be created without category
This commit is contained in:
@@ -51,6 +51,7 @@ class CategoriesService {
|
|||||||
if (!category) {
|
if (!category) {
|
||||||
throw new BadRequest('category does not exist')
|
throw new BadRequest('category does not exist')
|
||||||
}
|
}
|
||||||
|
// TODO this needs to reallocate all transactions under this category to unassigned
|
||||||
category.remove()
|
category.remove()
|
||||||
return category
|
return category
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { logger } from '../utils/Logger'
|
|||||||
|
|
||||||
class TransactionsService {
|
class TransactionsService {
|
||||||
async create(newTransaction) {
|
async create(newTransaction) {
|
||||||
|
if (newTransaction.categoryId == '') {
|
||||||
|
newTransaction.categoryId = null
|
||||||
|
}
|
||||||
const dbTransaction = await dbContext.Transactions.create(newTransaction)
|
const dbTransaction = await dbContext.Transactions.create(newTransaction)
|
||||||
if (!dbTransaction) {
|
if (!dbTransaction) {
|
||||||
throw new BadRequest("transaction does not exist")
|
throw new BadRequest("transaction does not exist")
|
||||||
|
|||||||
Reference in New Issue
Block a user