From 0e7db87e1644624f0beb1c37be6e3d23c4d5cf14 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Mon, 2 Mar 2020 17:12:18 +0000 Subject: [PATCH] Fix category deletion Signed-off-by: William Brawner --- .../com/wbrawner/budgetserver/category/CategoryController.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/wbrawner/budgetserver/category/CategoryController.kt b/src/main/kotlin/com/wbrawner/budgetserver/category/CategoryController.kt index e7be067..39e943c 100644 --- a/src/main/kotlin/com/wbrawner/budgetserver/category/CategoryController.kt +++ b/src/main/kotlin/com/wbrawner/budgetserver/category/CategoryController.kt @@ -125,11 +125,11 @@ open class CategoryController( .orElse(null) ?: return ResponseEntity.notFound().build() val budget = budgets.first { it.id == category.budget!!.id } - categoryRepository.delete(category) transactionRepository.findAllByBudgetAndCategory(budget, category) .forEach { transaction -> transactionRepository.save(transaction.copy(category = null)) } + categoryRepository.delete(category) return ResponseEntity.ok().build() } } \ No newline at end of file