Skip to content
Snippets Groups Projects
Commit 3cd724af authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #451 - categories page: show number of times used for each category

parent 84760159
No related branches found
No related tags found
No related merge requests found
Pipeline #1911 passed
package de.deadlocker8.budgetmaster.services;
import de.deadlocker8.budgetmaster.accounts.AccountService;
import de.deadlocker8.budgetmaster.categories.Category;
import de.deadlocker8.budgetmaster.database.accountmatches.AccountMatch;
import de.deadlocker8.budgetmaster.reports.Budget;
import de.deadlocker8.budgetmaster.settings.Settings;
......@@ -282,4 +283,9 @@ public class HelpersService
return DateTime.parse(cookieDate, DateTimeFormat.forPattern("dd.MM.yy").withLocale(getSettings().getLanguage().getLocale()));
}
}
public Long getUsageCountForCategory(Category category)
{
return transactionService.getRepository().countByCategory(category);
}
}
\ No newline at end of file
package de.deadlocker8.budgetmaster.transactions;
import de.deadlocker8.budgetmaster.categories.Category;
import de.deadlocker8.budgetmaster.tags.Tag;
import de.deadlocker8.budgetmaster.accounts.Account;
import org.joda.time.DateTime;
......@@ -18,6 +19,8 @@ public interface TransactionRepository extends JpaRepository<Transaction, Intege
List<Transaction> findAllByAccount(Account account);
Long countByCategory(Category category);
List<Transaction> findAllByTagsContaining(Tag tag);
@Query(value = "SELECT SUM(t.amount) FROM `transaction` as t WHERE t.account_id = ?1 AND t.transfer_account_id IS NULL AND t.date BETWEEN ?2 AND ?3", nativeQuery = true)
......
......@@ -141,6 +141,8 @@ menu.update=Update verf
menu.search.results=Suchergebnisse ({0})
category.new.label.name=Name
categories.usages=Verweise
categories.actions=Aktionen
settings.password=Passwort
settings.password.confirmation=Passwort Wiederholung
......
......@@ -142,6 +142,8 @@ menu.update=Update available
menu.search.results=Search results ({0})
category.new.label.name=Name
categories.usages=Usages
categories.actions=Actions
settings.password=Password
settings.password.confirmation=Password Confirmation
......
......@@ -24,8 +24,17 @@
<br>
<div class="container">
<table class="bordered">
<thead>
<tr>
<th></th>
<th>${locale.getString("category.new.label.name")}</th>
<th>${locale.getString("categories.usages")}</th>
<th>${locale.getString("categories.actions")}</th>
</tr>
</thead>
<#list categories as category>
<#assign categoryName=categoriesFunctions.getCategoryName(category)>
<#assign usageCount=helpers.getUsageCountForCategory(category)/>
<tr>
<td>
<div class="category-circle" style="background-color: ${category.color}">
......@@ -35,6 +44,7 @@
</div>
</td>
<td>${categoryName} </td>
<td>${usageCount}</td>
<td>
<a href="<@s.url '/categories/${category.ID?c}/edit'/>" class="btn-flat no-padding text-color"><i class="material-icons left">edit</i></a>
<#if (category.getType().name() == "CUSTOM")>
......
......@@ -226,6 +226,12 @@ public class DatabaseImportTest
return null;
}
@Override
public Long countByCategory(Category category)
{
return null;
}
@Override
public Page<Transaction> findAll(Specification<Transaction> specification, Pageable pageable)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment