Fix category deletion
Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
parent
94d2111ca6
commit
0e7db87e16
1 changed files with 1 additions and 1 deletions
|
@ -125,11 +125,11 @@ open class CategoryController(
|
||||||
.orElse(null)
|
.orElse(null)
|
||||||
?: return ResponseEntity.notFound().build()
|
?: return ResponseEntity.notFound().build()
|
||||||
val budget = budgets.first { it.id == category.budget!!.id }
|
val budget = budgets.first { it.id == category.budget!!.id }
|
||||||
categoryRepository.delete(category)
|
|
||||||
transactionRepository.findAllByBudgetAndCategory(budget, category)
|
transactionRepository.findAllByBudgetAndCategory(budget, category)
|
||||||
.forEach { transaction ->
|
.forEach { transaction ->
|
||||||
transactionRepository.save(transaction.copy(category = null))
|
transactionRepository.save(transaction.copy(category = null))
|
||||||
}
|
}
|
||||||
|
categoryRepository.delete(category)
|
||||||
return ResponseEntity.ok().build()
|
return ResponseEntity.ok().build()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue