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

#553 - show date of first transaction

parent 414a56b2
No related branches found
No related tags found
No related merge requests found
Pipeline #4647 failed
...@@ -4,7 +4,9 @@ import de.deadlocker8.budgetmaster.accounts.AccountService; ...@@ -4,7 +4,9 @@ import de.deadlocker8.budgetmaster.accounts.AccountService;
import de.deadlocker8.budgetmaster.categories.CategoryService; import de.deadlocker8.budgetmaster.categories.CategoryService;
import de.deadlocker8.budgetmaster.charts.ChartService; import de.deadlocker8.budgetmaster.charts.ChartService;
import de.deadlocker8.budgetmaster.charts.ChartType; import de.deadlocker8.budgetmaster.charts.ChartType;
import de.deadlocker8.budgetmaster.services.DateService;
import de.deadlocker8.budgetmaster.templates.TemplateService; import de.deadlocker8.budgetmaster.templates.TemplateService;
import de.deadlocker8.budgetmaster.transactions.Transaction;
import de.deadlocker8.budgetmaster.transactions.TransactionService; import de.deadlocker8.budgetmaster.transactions.TransactionService;
import de.thecodelabs.utils.util.Localization; import de.thecodelabs.utils.util.Localization;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -16,30 +18,49 @@ import java.util.List; ...@@ -16,30 +18,49 @@ import java.util.List;
@Service @Service
public class StatisticsService public class StatisticsService
{ {
private static final String TEXT_WHITE = "text-white";
private static final String TEXT_BLACK = "text-black";
private final AccountService accountService; private final AccountService accountService;
private final CategoryService categoryService; private final CategoryService categoryService;
private final TransactionService transactionService; private final TransactionService transactionService;
private final TemplateService templateService; private final TemplateService templateService;
private final ChartService chartService; private final ChartService chartService;
private final DateService dateService;
@Autowired @Autowired
public StatisticsService(AccountService accountService, CategoryService categoryService, TransactionService transactionService, TemplateService templateService, ChartService chartService) public StatisticsService(AccountService accountService, CategoryService categoryService, TransactionService transactionService, TemplateService templateService, ChartService chartService, DateService dateService)
{ {
this.accountService = accountService; this.accountService = accountService;
this.categoryService = categoryService; this.categoryService = categoryService;
this.transactionService = transactionService; this.transactionService = transactionService;
this.templateService = templateService; this.templateService = templateService;
this.chartService = chartService; this.chartService = chartService;
this.dateService = dateService;
} }
public List<StatisticItem> getStatisticItems() public List<StatisticItem> getStatisticItems()
{ {
final List<StatisticItem> statisticItems = new ArrayList<>(); final List<StatisticItem> statisticItems = new ArrayList<>();
statisticItems.add(new StatisticItem("account_balance", Localization.getString("statistics.number.of.accounts", accountService.getAllAccountsAsc().size()), "background-red", "text-white")); statisticItems.add(new StatisticItem("account_balance", Localization.getString("statistics.number.of.accounts", accountService.getAllAccountsAsc().size()), "background-red", TEXT_WHITE));
statisticItems.add(new StatisticItem("list", Localization.getString("statistics.number.of.transactions", transactionService.getRepository().findAll().size()), "background-blue-baby", "text-white")); statisticItems.add(new StatisticItem("list", Localization.getString("statistics.number.of.transactions", transactionService.getRepository().findAll().size()), "background-blue-baby", TEXT_BLACK));
statisticItems.add(new StatisticItem("file_copy", Localization.getString("statistics.number.of.templates", templateService.getRepository().findAll().size()), "background-orange-dark", "text-white")); statisticItems.add(new StatisticItem("file_copy", Localization.getString("statistics.number.of.templates", templateService.getRepository().findAll().size()), "background-orange-dark", TEXT_BLACK));
statisticItems.add(new StatisticItem("show_chart", Localization.getString("statistics.number.of.custom.charts", chartService.getRepository().findAllByType(ChartType.CUSTOM).size()), "background-purple", "text-white")); statisticItems.add(new StatisticItem("show_chart", Localization.getString("statistics.number.of.custom.charts", chartService.getRepository().findAllByType(ChartType.CUSTOM).size()), "background-purple", TEXT_WHITE));
statisticItems.add(new StatisticItem("label", Localization.getString("statistics.number.of.categories", categoryService.getAllCategories().size()), "background-orange", "text-black")); statisticItems.add(new StatisticItem("label", Localization.getString("statistics.number.of.categories", categoryService.getAllCategories().size()), "background-orange", TEXT_BLACK));
statisticItems.add(new StatisticItem("event", Localization.getString("statistics.first.transaction", getFirstTransactionDate()), "background-grey", TEXT_BLACK));
return statisticItems; return statisticItems;
} }
private String getFirstTransactionDate()
{
final Transaction firstTransaction = transactionService.getRepository().findFirstByOrderByDate();
String firstTransactionDate = "-";
if(firstTransaction != null)
{
firstTransactionDate = dateService.getDateStringNormal(firstTransaction.getDate());
}
return firstTransactionDate;
}
} }
...@@ -36,4 +36,6 @@ public interface TransactionRepository extends JpaRepository<Transaction, Intege ...@@ -36,4 +36,6 @@ public interface TransactionRepository extends JpaRepository<Transaction, Intege
List<Transaction> findAllByTransferAccount(Account account); List<Transaction> findAllByTransferAccount(Account account);
List<Transaction> findAllByOrderByDateDesc(); List<Transaction> findAllByOrderByDateDesc();
Transaction findFirstByOrderByDate();
} }
\ No newline at end of file
...@@ -523,3 +523,4 @@ statistics.number.of.transactions={0} Buchungen ...@@ -523,3 +523,4 @@ statistics.number.of.transactions={0} Buchungen
statistics.number.of.templates={0} Vorlagen statistics.number.of.templates={0} Vorlagen
statistics.number.of.custom.charts={0} Eigene Diagramme statistics.number.of.custom.charts={0} Eigene Diagramme
statistics.number.of.categories={0} Kategorien statistics.number.of.categories={0} Kategorien
statistics.first.transaction=Erste Buchung {0}
...@@ -521,3 +521,4 @@ statistics.number.of.transactions={0} Transactions ...@@ -521,3 +521,4 @@ statistics.number.of.transactions={0} Transactions
statistics.number.of.templates={0} Templates statistics.number.of.templates={0} Templates
statistics.number.of.custom.charts={0} Custom Charts statistics.number.of.custom.charts={0} Custom Charts
statistics.number.of.categories={0} Categories statistics.number.of.categories={0} Categories
statistics.first.transaction=First Transaction {0}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment