From 419a0dce325b8f96555a8836d71a7a5e203ba671 Mon Sep 17 00:00:00 2001 From: GEXCE Date: Tue, 7 Jan 2020 17:02:49 +0100 Subject: [PATCH] bugfix for budgets --- .../de/tilman/transactions/repository/CategoryRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/tilman/transactions/repository/CategoryRepository.java b/src/main/java/de/tilman/transactions/repository/CategoryRepository.java index 4ee8ebf..ec0cb8b 100644 --- a/src/main/java/de/tilman/transactions/repository/CategoryRepository.java +++ b/src/main/java/de/tilman/transactions/repository/CategoryRepository.java @@ -21,12 +21,12 @@ public interface CategoryRepository extends PagingAndSortingRepository (CURRENT_DATE() - DAY_OF_YEAR(CURRENT_DATE()))") + @Query("SELECT sum(t.amount) FROM Transaction t WHERE t.account.id = :accountId AND t.category.id = :categoryId and DATE > (CURRENT_DATE() - DAY_OF_YEAR(CURRENT_DATE()) + 1)") Double getYearExpenseLevelForCategory(@Param("accountId") Long accountId, @Param("categoryId") Long categoryId); // http://localhost:8084/api/categories/search/expenseLevelMonth?accountId=2&categoryId=5 @RestResource(path = "expenseLevelMonth") - @Query("SELECT sum(t.amount) FROM Transaction t WHERE t.account.id = :accountId AND t.category.id = :categoryId and DATE > (CURRENT_DATE() - DAY_OF_MONTH(CURRENT_DATE()))") + @Query("SELECT sum(t.amount) FROM Transaction t WHERE t.account.id = :accountId AND t.category.id = :categoryId and DATE > (CURRENT_DATE() - DAY_OF_MONTH(CURRENT_DATE()) + 1)") Double getMonthExpenseLevelForCategory(@Param("accountId") Long accountId, @Param("categoryId") Long categoryId); @PreAuthorize("hasRole('ROLE_ADMIN')")