Skip to content

Commit

Permalink
Merge branch 'v2_15_0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Jun 21, 2023
2 parents 25f26f1 + 0fedd38 commit 47fc0c0
Show file tree
Hide file tree
Showing 41 changed files with 719 additions and 505 deletions.
50 changes: 10 additions & 40 deletions BudgetMasterServer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>BudgetMaster</artifactId>
<groupId>de.deadlocker8</groupId>
<version>2.14.0</version>
<version>2.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -26,23 +26,23 @@
<properties>
<jlibs.version>3.2.0</jlibs.version>
<versionizer.version>3.0.1</versionizer.version>
<webjars-locator.version>0.46</webjars-locator.version>
<jquery.version>3.6.3</jquery.version>
<webjars-locator.version>0.47</webjars-locator.version>
<jquery.version>3.6.4</jquery.version>
<materializecss.version>1.0.0</materializecss.version>
<fontawesome.version>6.3.0</fontawesome.version>
<fontawesome.version>6.4.0</fontawesome.version>
<sortablejs.version>1.15.0</sortablejs.version>
<mousetrap.version>1.6.5</mousetrap.version>
<codemirror.version>5.62.2</codemirror.version>
<selenium.version>4.8.1</selenium.version>
<jgit.version>6.4.0.202211300538-r</jgit.version>
<selenium.version>4.10.0</selenium.version>
<jgit.version>6.6.0.202305301015-r</jgit.version>
<natorder.version>1.1.3</natorder.version>
<itextpdf.version>5.5.13.3</itextpdf.version>
<vanilla-picker.version>2.12.1</vanilla-picker.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.10</jacoco-maven-plugin.version>
<opencsv.version>5.7.1</opencsv.version>
<datatables.version>1.13.2</datatables.version>
<datatables.version>1.13.4</datatables.version>
<jakarta.xml.bind-api.version>4.0.0</jakarta.xml.bind-api.version>
<junit-jupiter-engine.version>5.9.2</junit-jupiter-engine.version>
<junit-jupiter-engine.version>5.9.3</junit-jupiter-engine.version>

<project.outputDirectory>${project.build.directory}/../build/${project.version}</project.outputDirectory>
<project.artifactName>${project.artifactId}-v${project.version}</project.artifactName>
Expand Down Expand Up @@ -80,11 +80,6 @@
<version>${jakarta.xml.bind-api.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
Expand Down Expand Up @@ -218,12 +213,6 @@
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -243,29 +232,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<webappDirectory>${basedir}/src/main</webappDirectory>
<outputDirectory>${project.outputDirectory}</outputDirectory>
<warName>${project.artifactName}</warName>
</configuration>
<executions>
<execution>
<id>war-packaging</id>
<goals>
<goal>war</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M9</version>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DefaultCharts

private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_BY_CATEGORIES = new Chart("charts.default.incomesAndExpendituresPerMonthByCategories",
getChartFromFile("charts/IncomesAndExpendituresPerMonthByCategories.js"),
ChartType.DEFAULT, 25, ChartDisplayType.BAR, ChartGroupType.MONTH, "incomesAndExpendituresPerMonthByCategories.png");
ChartType.DEFAULT, 27, ChartDisplayType.BAR, ChartGroupType.MONTH, "incomesAndExpendituresPerMonthByCategories.png");

private static final Chart CHART_REST_PER_MONTH = new Chart("charts.default.restPerMonth",
getChartFromFile("charts/RestPerMonth.js"),
Expand All @@ -52,7 +52,7 @@ public class DefaultCharts

private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_YEAR_BY_CATEGORIES = new Chart("charts.default.incomesAndExpendituresPerYearByCategories",
getChartFromFile("charts/IncomesAndExpendituresPerYearByCategories.js"),
ChartType.DEFAULT, 5, ChartDisplayType.BAR, ChartGroupType.YEAR, "incomesAndExpendituresPerYearByCategories.png");
ChartType.DEFAULT, 7, ChartDisplayType.BAR, ChartGroupType.YEAR, "incomesAndExpendituresPerYearByCategories.png");

private static final Chart CHART_AVERAGE_TRANSACTION_AMOUNT_PER_CATEGORY = new Chart("charts.default.averageTransactionAmountPerCategory",
getChartFromFile("charts/AverageTransactionAmountPerCategoryBar.js"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ public String index(Model model)
public String whatsNewModal(Model model)
{
final List<NewsEntry> newsEntries = new ArrayList<>();
newsEntries.add(NewsEntry.createWithLocalizationKey("csvImportSave"));
newsEntries.add(NewsEntry.createWithLocalizationKey("csvImportSuggestions"));
newsEntries.add(NewsEntry.createWithLocalizationKey("csvImportAmountSeparators"));
newsEntries.add(NewsEntry.createWithLocalizationKey("dockerImageSize"));
newsEntries.add(NewsEntry.createWithLocalizationKey("csvImportAvoidPageReload"));
newsEntries.add(NewsEntry.createWithLocalizationKey("csvImportBugfixFloatingPointPrecision"));
newsEntries.add(NewsEntry.createWithLocalizationKey("csvImportBugfixTemplateAndCategory"));
newsEntries.add(NewsEntry.createWithLocalizationKey("sortCategoriesInCharts"));
newsEntries.add(NewsEntry.createWithLocalizationKey("filterBugfix"));

model.addAttribute(ModelAttributes.NEWS_ENTRIES, newsEntries);
return ReturnValues.WHATS_NEW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.WebRequest;

import java.io.IOException;
import java.text.MessageFormat;
import java.time.LocalDate;
Expand Down Expand Up @@ -68,13 +71,14 @@ public ReportController(ReportSettingsService reportSettingsService, ReportGener
}

@GetMapping
public String reports(HttpServletRequest request, Model model, @CookieValue(value = "currentDate", required = false) String cookieDate)
public String reports(WebRequest webRequest, HttpServletRequest request, Model model, @CookieValue(value = "currentDate", required = false) String cookieDate)
{
LocalDate date = dateService.getDateTimeFromCookie(cookieDate);

model.addAttribute(ModelAttributes.REPORT_SETTINGS, reportSettingsService.getReportSettings());
model.addAttribute(ModelAttributes.CURRENT_DATE, date);
model.addAttribute(ModelAttributes.FILTER_CONFIGURATION, filterHelpers.getFilterConfiguration(request));

webRequest.setAttribute(ModelAttributes.FILTER_CONFIGURATION, filterHelpers.getFilterConfiguration(request), RequestAttributes.SCOPE_SESSION);
return ReturnValues.ALL_ENTITIES;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class Template implements TransactionBase, Iconizable
name = "tags_id", referencedColumnName = "ID"))
private List<Tag> tags;

@OneToOne(optional = true)
@ManyToOne(optional = true)
@Expose
private Account transferAccount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ private void overrideFieldsFromCsvTransaction(WebRequest request, Transaction tr
transaction.setDate(csvTransaction.getDate());
transaction.setAmount(csvTransaction.getAmount());
transaction.setIsExpenditure(csvTransaction.getAmount() <= 0);
transaction.setCategory(csvTransaction.getCategory());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class Transaction implements TransactionBase, ProvidesID
@Expose
private RepeatingOption repeatingOption;

@OneToOne(optional = true)
@ManyToOne(optional = true)
@Expose
private Account transferAccount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,40 +88,41 @@ public TransactionController(TransactionService transactionService, CategoryServ
}

@GetMapping
public String transactions(HttpServletRequest request, Model model, @CookieValue(value = "currentDate", required = false) String cookieDate)
public String transactions(WebRequest webRequest, HttpServletRequest request, Model model, @CookieValue(value = "currentDate", required = false) String cookieDate)
{
LocalDate date = dateService.getDateTimeFromCookie(cookieDate);
repeatingTransactionUpdater.updateRepeatingTransactions(date.with(lastDayOfMonth()));

prepareModelTransactions(filterHelpers.getFilterConfiguration(request), model, date);
prepareModelTransactions(webRequest, filterHelpers.getFilterConfiguration(request), model, date);

return ReturnValues.ALL_ENTITIES;
}

@GetMapping("/{ID}/requestDelete")
public String requestDeleteTransaction(HttpServletRequest request, Model model, @PathVariable("ID") Integer ID, @CookieValue("currentDate") String cookieDate)
public String requestDeleteTransaction(WebRequest webRequest, HttpServletRequest request, Model model, @PathVariable("ID") Integer ID, @CookieValue("currentDate") String cookieDate)
{
if(!transactionService.isDeletable(ID))
{
return ReturnValues.REDIRECT_ALL_ENTITIES;
}

LocalDate date = dateService.getDateTimeFromCookie(cookieDate);
prepareModelTransactions(filterHelpers.getFilterConfiguration(request), model, date);
prepareModelTransactions(webRequest, filterHelpers.getFilterConfiguration(request), model, date);
model.addAttribute(TransactionModelAttributes.ENTITY_TO_DELETE, transactionService.getRepository().getReferenceById(ID));

return ReturnValues.DELETE_ENTITY;
}

private void prepareModelTransactions(FilterConfiguration filterConfiguration, Model model, LocalDate date)
private void prepareModelTransactions(WebRequest webRequest, FilterConfiguration filterConfiguration, Model model, LocalDate date)
{
final Account currentAccount = helpers.getCurrentAccount();
final List<Transaction> transactions = transactionService.getTransactionsForMonthAndYear(currentAccount, date.getMonthValue(), date.getYear(), filterConfiguration);

model.addAttribute(TransactionModelAttributes.ACCOUNT, currentAccount);
model.addAttribute(TransactionModelAttributes.BUDGET, helpers.getBudget(transactions, currentAccount));
model.addAttribute(TransactionModelAttributes.CURRENT_DATE, date);
model.addAttribute(TransactionModelAttributes.FILTER_CONFIGURATION, filterConfiguration);

webRequest.setAttribute("filterConfiguration", filterConfiguration, RequestAttributes.SCOPE_SESSION);

if(settingsService.getSettings().isRestActivated())
{
Expand Down Expand Up @@ -310,7 +311,7 @@ public String editTransaction(Model model, @CookieValue("currentDate") String co
}

@GetMapping("/{ID}/highlight")
public String highlight(Model model, @PathVariable("ID") Integer ID)
public String highlight(WebRequest webRequest, Model model, @PathVariable("ID") Integer ID)
{
Transaction transaction = transactionService.getRepository().getReferenceById(ID);

Expand All @@ -326,7 +327,7 @@ public String highlight(Model model, @PathVariable("ID") Integer ID)
filterConfiguration.setFilterCategories(filterHelpers.getFilterCategories());
filterConfiguration.setFilterTags(filterHelpers.getFilterTags());

prepareModelTransactions(filterConfiguration, model, transaction.getDate());
prepareModelTransactions(webRequest, filterConfiguration, model, transaction.getDate());
model.addAttribute(TransactionModelAttributes.HIGHLIGHT_ID, ID);
return ReturnValues.ALL_ENTITIES;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.deadlocker8.budgetmaster.controller.BaseController;
import de.deadlocker8.budgetmaster.transactions.csvimport.*;
import de.deadlocker8.budgetmaster.utils.Mappings;
import de.deadlocker8.budgetmaster.utils.ResourceNotFoundException;
import de.deadlocker8.budgetmaster.utils.WebRequestUtils;
import de.deadlocker8.budgetmaster.utils.notification.Notification;
import de.deadlocker8.budgetmaster.utils.notification.NotificationType;
Expand Down Expand Up @@ -32,6 +33,8 @@ private static class ModelAttributes
public static final String ERROR = "error";
public static final String CATEGORIES = "categories";
public static final String CSV_IMPORT_SETTINGS = "csvImportSettings";
public static final String CSV_TRANSACTION = "csvTransaction";
public static final String CSV_TRANSACTION_INDEX = "csvTransactionIndex";
}

private static class ReturnValues
Expand All @@ -41,6 +44,7 @@ private static class ReturnValues
public static final String REDIRECT_CANCEL = "redirect:/transactionImport/cancel";
public static final String NEW_TRANSACTION_NORMAL = "transactions/newTransactionNormal";
public static final String NEW_TRANSACTION_TRANSFER = "transactions/newTransactionTransfer";
public static final String TRANSACTION_IMPORT_ROW = "transactions/transactionImportRow";
public static final String REDIRECT_TEMPLATES = "redirect:/templates";
}

Expand Down Expand Up @@ -201,29 +205,41 @@ public String cancel(WebRequest request)
}

@GetMapping("/{index}/skip")
public String skip(WebRequest request, @PathVariable("index") Integer index)
public String skip(Model model, WebRequest request, @PathVariable("index") Integer index)
{
final Optional<CsvTransaction> transactionOptional = getTransactionByIndex(request, index);
if(transactionOptional.isEmpty())
{
return ReturnValues.REDIRECT_IMPORT;
throw new ResourceNotFoundException();
}

transactionOptional.get().setStatus(CsvTransactionStatus.SKIPPED);
return ReturnValues.REDIRECT_IMPORT;
final CsvTransaction csvTransaction = transactionOptional.get();
csvTransaction.setStatus(CsvTransactionStatus.SKIPPED);

model.addAttribute(ModelAttributes.CATEGORIES, categoryService.getAllEntitiesAsc());
model.addAttribute(TransactionModelAttributes.SUGGESTIONS_JSON, transactionService.getNameSuggestionsJson());
model.addAttribute(ModelAttributes.CSV_TRANSACTION, csvTransaction);
model.addAttribute(ModelAttributes.CSV_TRANSACTION_INDEX, index);
return ReturnValues.TRANSACTION_IMPORT_ROW;
}

@GetMapping("/{index}/undoSkip")
public String undoSkip(WebRequest request, @PathVariable("index") Integer index)
public String undoSkip(Model model, WebRequest request, @PathVariable("index") Integer index)
{
final Optional<CsvTransaction> transactionOptional = getTransactionByIndex(request, index);
if(transactionOptional.isEmpty())
{
return ReturnValues.REDIRECT_IMPORT;
throw new ResourceNotFoundException();
}

transactionOptional.get().setStatus(CsvTransactionStatus.PENDING);
return ReturnValues.REDIRECT_IMPORT;
final CsvTransaction csvTransaction = transactionOptional.get();
csvTransaction.setStatus(CsvTransactionStatus.PENDING);

model.addAttribute(ModelAttributes.CATEGORIES, categoryService.getAllEntitiesAsc());
model.addAttribute(TransactionModelAttributes.SUGGESTIONS_JSON, transactionService.getNameSuggestionsJson());
model.addAttribute(ModelAttributes.CSV_TRANSACTION, csvTransaction);
model.addAttribute(ModelAttributes.CSV_TRANSACTION_INDEX, index);
return ReturnValues.TRANSACTION_IMPORT_ROW;
}

@GetMapping("/{index}/newTransaction/{type}")
Expand Down Expand Up @@ -269,14 +285,14 @@ public String newFromTemplate(WebRequest request,
}

@PostMapping("/{index}/newTransactionInPlace")
public String newTransactionInPlace(WebRequest request,
public String newTransactionInPlace(Model model, WebRequest request,
@PathVariable("index") Integer index,
@ModelAttribute("NewTransactionInPlace") CsvTransaction newCsvTransaction)
{
final Optional<CsvTransaction> transactionOptional = getTransactionByIndex(request, index);
if(transactionOptional.isEmpty())
{
return ReturnValues.REDIRECT_IMPORT;
throw new ResourceNotFoundException();
}

final CsvTransaction csvTransaction = transactionOptional.get();
Expand All @@ -287,7 +303,11 @@ public String newTransactionInPlace(WebRequest request,
final Transaction newTransaction = transactionImportService.createTransactionFromCsvTransaction(csvTransaction);
transactionService.getRepository().save(newTransaction);

return ReturnValues.REDIRECT_IMPORT;
model.addAttribute(ModelAttributes.CATEGORIES, categoryService.getAllEntitiesAsc());
model.addAttribute(TransactionModelAttributes.SUGGESTIONS_JSON, transactionService.getNameSuggestionsJson());
model.addAttribute(ModelAttributes.CSV_TRANSACTION, csvTransaction);
model.addAttribute(ModelAttributes.CSV_TRANSACTION_INDEX, index);
return ReturnValues.TRANSACTION_IMPORT_ROW;
}

private void removeAllAttributes(WebRequest request)
Expand All @@ -309,6 +329,13 @@ private Optional<CsvTransaction> getTransactionByIndex(WebRequest request, Integ
}

final List<CsvTransaction> csvTransactions = (List<CsvTransaction>) attribute;
return Optional.of(csvTransactions.get(index));
try
{
return Optional.of(csvTransactions.get(index));
}
catch(IndexOutOfBoundsException e)
{
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static Optional<Integer> parse(String amountString, char decimalSeparator
throw new ParseException("String not fully parsed", parsePosition.getIndex());
}

return Optional.of((int) (parseDouble * 100));
return Optional.of((int) Math.round(parseDouble * 100));
}
catch(ParseException e)
{
Expand Down
Loading

0 comments on commit 47fc0c0

Please sign in to comment.