hot fix
This commit is contained in:
@@ -204,20 +204,22 @@ class FinancialService(
|
||||
isCategoryChanged: Boolean = false,
|
||||
isOldCategory: Boolean = false
|
||||
): Double {
|
||||
val sums = getBudgetSumsByCategory(transaction.category.id!!, budget)
|
||||
val categoryBudget = budget.categories.firstOrNull { it.category.id == transaction.category.id }
|
||||
?: throw NotFoundException("Not found category in budget")
|
||||
categoryBudget.currentPlanned = sums.getDouble("plannedAmount")
|
||||
categoryBudget.currentSpent = sums.getDouble("instantAmount")
|
||||
if (transaction.type.code == "PLANNED") {
|
||||
if (isCategoryChanged) {
|
||||
if (isOldCategory) {
|
||||
categoryBudget.currentLimit -= transaction.amount
|
||||
} else categoryBudget.currentLimit += transaction.amount
|
||||
} else categoryBudget.currentLimit += difference
|
||||
}
|
||||
budgetRepo.save(budget).awaitSingle()
|
||||
return 1.0
|
||||
return if (transaction.category.type.code == "EXPENSE") {
|
||||
val sums = getBudgetSumsByCategory(transaction.category.id!!, budget)
|
||||
val categoryBudget = budget.categories.firstOrNull { it.category.id == transaction.category.id }
|
||||
?: throw NotFoundException("Not found category in budget")
|
||||
categoryBudget.currentPlanned = sums.getDouble("plannedAmount")
|
||||
categoryBudget.currentSpent = sums.getDouble("instantAmount")
|
||||
if (transaction.type.code == "PLANNED") {
|
||||
if (isCategoryChanged) {
|
||||
if (isOldCategory) {
|
||||
categoryBudget.currentLimit -= transaction.amount
|
||||
} else categoryBudget.currentLimit += transaction.amount
|
||||
} else categoryBudget.currentLimit += difference
|
||||
}
|
||||
budgetRepo.save(budget).awaitSingle()
|
||||
1.0
|
||||
} else 0.0
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user