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