fix: budgets showing wrong value
This commit is contained in:
@@ -48,6 +48,10 @@ public class BudgetResource {
|
||||
User user = currentUser.require();
|
||||
LocalDate start = LocalDate.parse(yearMonth + "-01");
|
||||
LocalDate end = start.plusMonths(1).minusDays(1);
|
||||
LocalDate today = LocalDate.now();
|
||||
if (end.isAfter(today)) {
|
||||
end = today;
|
||||
}
|
||||
|
||||
return em.createQuery(
|
||||
"SELECT new com.ledger.budget.CategorySpend(t.category.id, t.category.name, SUM(t.amount)) " +
|
||||
|
||||
@@ -48,7 +48,7 @@ export default function Budgets() {
|
||||
);
|
||||
|
||||
const totalBudgeted = budgets.reduce((s, b) => s + Number(b.limitAmount), 0);
|
||||
const totalSpent = Object.values(spendByCategory).reduce((s, v) => s + v, 0);
|
||||
const totalSpent = budgets.reduce((s, b) => s + (spendByCategory[b.category?.id] || 0), 0);
|
||||
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [categoryId, setCategoryId] = useState('');
|
||||
|
||||
Reference in New Issue
Block a user