From 2aa0f7fa9cd9fe6f64d643fafb499663f23a9545 Mon Sep 17 00:00:00 2001 From: MK13 Date: Thu, 4 Mar 2021 23:39:50 +0100 Subject: [PATCH] #17 Period overview: add Actions --- .../controller/TransactionController.java | 4 +-- .../financer/controller/PeriodController.java | 32 +++++++++++++++++++ .../main/resources/i18n/message.properties | 2 ++ .../resources/i18n/message_de_DE.properties | 2 ++ .../src/main/resources/static/changelog.txt | 3 ++ .../templates/period/periodOverview.html | 8 ++++- 6 files changed, 48 insertions(+), 3 deletions(-) diff --git a/financer-server/src/main/java/de/financer/controller/TransactionController.java b/financer-server/src/main/java/de/financer/controller/TransactionController.java index d72bd57..d328e07 100644 --- a/financer-server/src/main/java/de/financer/controller/TransactionController.java +++ b/financer-server/src/main/java/de/financer/controller/TransactionController.java @@ -48,8 +48,8 @@ public class TransactionController { String taxRelevant, String accountsAnd, String hasFile) { - final String fromDecoded = ControllerUtil.urlDecode(fromAccountKey); - final String toDecoded = ControllerUtil.urlDecode(toAccountKey); + final String fromDecoded = fromAccountKey != null ? ControllerUtil.urlDecode(fromAccountKey) : null; + final String toDecoded = toAccountKey != null ? ControllerUtil.urlDecode(toAccountKey) : null; if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("GET /transactions/ got parameter: %s, %s, %s, %s, %s, %s, %s - with order %s", diff --git a/financer-web-client/src/main/java/de/financer/controller/PeriodController.java b/financer-web-client/src/main/java/de/financer/controller/PeriodController.java index 7c4b70e..e004c52 100644 --- a/financer-web-client/src/main/java/de/financer/controller/PeriodController.java +++ b/financer-web-client/src/main/java/de/financer/controller/PeriodController.java @@ -1,12 +1,16 @@ package de.financer.controller; import de.financer.config.FinancerConfig; +import de.financer.dto.Order; import de.financer.dto.PeriodOverviewDto; import de.financer.dto.SearchTransactionsResponseDto; +import de.financer.form.SearchTransactionsForm; import de.financer.template.FinancerRestTemplate; +import de.financer.template.SearchTransactionsTemplate; import de.financer.template.StringTemplate; import de.financer.template.exception.FinancerRestException; import de.financer.util.ControllerUtils; +import org.apache.commons.collections4.IterableUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; import org.springframework.stereotype.Controller; @@ -53,4 +57,32 @@ public class PeriodController { return "period/periodOverview"; } + + @GetMapping("/showTransactions") + public String showTransactions(Model model, Long periodId) { + try { + final Iterable response = + new SearchTransactionsTemplate() + .exchangeGet(financerConfig, null, null, periodId, null, + Order.TRANSACTIONS_BY_DATE_DESC, null, false); + + final List transactions = IterableUtils.toList(response); + + + model.addAttribute("transactions", transactions); + model.addAttribute("transactionCount", IterableUtils.size(transactions)); + } + catch(FinancerRestException e) { + model.addAttribute("errorMessage", e.getResponseReason().name()); + model.addAttribute("transactionCount", 0); + } + + model.addAttribute("form", new SearchTransactionsForm()); + model.addAttribute("showSum", false); + ControllerUtils.addVersionAttribute(model, this.financerConfig); + ControllerUtils.addCurrencySymbol(model, this.financerConfig); + ControllerUtils.addDarkMode(model, this.financerConfig); + + return "transaction/searchTransactions"; + } } diff --git a/financer-web-client/src/main/resources/i18n/message.properties b/financer-web-client/src/main/resources/i18n/message.properties index 85a4cba..e220c96 100644 --- a/financer-web-client/src/main/resources/i18n/message.properties +++ b/financer-web-client/src/main/resources/i18n/message.properties @@ -184,6 +184,8 @@ financer.period-overview.table-header.liability=Liabilities financer.period-overview.table-header.total=Total financer.period-overview.table-header.assets=Assets financer.period-overview.table-header.transactions=Transaction count +financer.period-overview.table-header.actions=Actions +financer.period-overview.table.actions.showTransactions=Show transactions financer.interval-type.DAILY=Daily financer.interval-type.WEEKLY=Weekly diff --git a/financer-web-client/src/main/resources/i18n/message_de_DE.properties b/financer-web-client/src/main/resources/i18n/message_de_DE.properties index 33cd2e8..573b99d 100644 --- a/financer-web-client/src/main/resources/i18n/message_de_DE.properties +++ b/financer-web-client/src/main/resources/i18n/message_de_DE.properties @@ -184,6 +184,8 @@ financer.period-overview.table-header.liability=Verbindlichkeiten financer.period-overview.table-header.total=Insgesamt financer.period-overview.table-header.assets=Umlaufverm\u00F6gen financer.period-overview.table-header.transactions=Anzahl Buchungen +financer.period-overview.table-header.actions=Aktionen +financer.period-overview.table.actions.showTransactions=Zeige Buchungen financer.interval-type.DAILY=T\u00E4glich financer.interval-type.WEEKLY=W\u00F6chentlich diff --git a/financer-web-client/src/main/resources/static/changelog.txt b/financer-web-client/src/main/resources/static/changelog.txt index 34ce47a..df067cf 100644 --- a/financer-web-client/src/main/resources/static/changelog.txt +++ b/financer-web-client/src/main/resources/static/changelog.txt @@ -1,3 +1,6 @@ +v45 -> v46: +- #17 Add actions to the period overview + v44 -> v45: - #5 Having no periods breaks the "expenses per period" graph on the account overview page - #14 Introduce toggleable dark mode diff --git a/financer-web-client/src/main/resources/templates/period/periodOverview.html b/financer-web-client/src/main/resources/templates/period/periodOverview.html index 0df4fd4..00540a5 100644 --- a/financer-web-client/src/main/resources/templates/period/periodOverview.html +++ b/financer-web-client/src/main/resources/templates/period/periodOverview.html @@ -25,6 +25,7 @@ + @@ -44,9 +45,14 @@ - + +
+ +
+