Expenses on budget per month
This commit is contained in:
@@ -19,10 +19,15 @@ public interface CategoryRepository extends PagingAndSortingRepository<Category,
|
||||
@RestResource(path = "listForAccount")
|
||||
List<Category> findByAccountIdOrderByPositionAsc(@Param("accountId") Long accountId);
|
||||
|
||||
// http://localhost:8084/api/categories/search/expenseLevel?accountId=1&categoryId=1
|
||||
@RestResource(path = "expenseLevel")
|
||||
// http://localhost:8084/api/categories/search/expenseLevelYear?accountId=1&categoryId=1
|
||||
@RestResource(path = "expenseLevelYear")
|
||||
@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()))")
|
||||
Integer getExpenseLevelForCategory(@Param("accountId") Long accountId, @Param("categoryId") Long categoryId);
|
||||
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()))")
|
||||
Double getMonthExpenseLevelForCategory(@Param("accountId") Long accountId, @Param("categoryId") Long categoryId);
|
||||
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@Override
|
||||
|
||||
@@ -73,6 +73,6 @@ INSERT INTO Transaction (id, amount, account_id, category_id, date, description,
|
||||
INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, -1.50, 1, 3, '2019-10-01', 'Transaction28', null); Commit;
|
||||
INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, -1.50, 1, 1, '2019-10-01', 'Transaction29', null); Commit;
|
||||
INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, -1.50, 1, 3, '2019-10-01', 'Transaction30', null); Commit;
|
||||
INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, 1.50, 2, 5, CURRENT_TIMESTAMP()+1, 'LAST Transaction', null); Commit;
|
||||
INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES (NULL, 1.90, 2, 5, CURRENT_TIMESTAMP()+1, 'LAST Transaction', null); Commit;
|
||||
|
||||
--SCRIPT TO 'h2export.sql';
|
||||
Reference in New Issue
Block a user