Skip to content

Commit

Permalink
Merge branch 'v2_17_0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Oct 5, 2024
2 parents 3072fd3 + b128687 commit 39998ba
Show file tree
Hide file tree
Showing 89 changed files with 5,120 additions and 303 deletions.
26 changes: 13 additions & 13 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.16.1</version>
<version>2.17.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.50</webjars-locator.version>
<webjars-locator.version>0.52</webjars-locator.version>
<jquery.version>3.7.1</jquery.version>
<materializecss.version>1.0.0</materializecss.version>
<fontawesome.version>6.4.2</fontawesome.version>
<sortablejs.version>1.15.1</sortablejs.version>
<fontawesome.version>6.5.2</fontawesome.version>
<sortablejs.version>1.15.3</sortablejs.version>
<mousetrap.version>1.6.5</mousetrap.version>
<codemirror.version>5.62.2</codemirror.version>
<selenium.version>4.15.0</selenium.version>
<jgit.version>6.7.0.202309050840-r</jgit.version>
<selenium.version>4.25.0</selenium.version>
<jgit.version>7.0.0.202409031743-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.11</jacoco-maven-plugin.version>
<itextpdf.version>5.5.13.4</itextpdf.version>
<vanilla-picker.version>2.12.3</vanilla-picker.version>
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<opencsv.version>5.9</opencsv.version>
<datatables.version>1.13.5</datatables.version>
<jakarta.xml.bind-api.version>4.0.1</jakarta.xml.bind-api.version>
<junit-jupiter-engine.version>5.10.1</junit-jupiter-engine.version>
<datatables.version>2.1.0</datatables.version>
<jakarta.xml.bind-api.version>4.0.2</jakarta.xml.bind-api.version>
<junit-jupiter-engine.version>5.11.2</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 @@ -235,7 +235,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
<version>3.5.0</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import de.deadlocker8.budgetmaster.icon.Iconizable;
import de.deadlocker8.budgetmaster.transactions.Transaction;
import de.deadlocker8.budgetmaster.utils.ProvidesID;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -45,36 +48,34 @@ public class Account implements ProvidesID, Iconizable
@Expose
private AccountType type;

public Account(String name, AccountType type, Icon iconReference)
@Expose
private String description;

@DateTimeFormat(pattern = "dd.MM.yyyy")
@Expose
private LocalDate endDate;

public Account(String name, String description, AccountType type, Icon iconReference, LocalDate endDate)
{
this.name = name;
this.description = description;
this.type = type;
this.isSelected = false;
this.isDefault = false;
this.accountState = AccountState.FULL_ACCESS;
this.iconReference = iconReference;
this.endDate = endDate;
}

public Account(String name, AccountType type)
public Account(String name, String description, AccountType type, LocalDate endDate)
{
this(name, type, null);
this(name, description, type, null, endDate);
}

public Account()
{
}

public void updateFromOtherAccount(Account otherAccount)
{
this.setID(otherAccount.ID);
this.setName(otherAccount.name);
this.setType(otherAccount.type);
this.setSelected(otherAccount.isSelected);
this.setDefault(otherAccount.isDefault);
this.setAccountState(otherAccount.accountState);
this.setIconReference(otherAccount.iconReference);
}

public Integer getID()
{
return ID;
Expand Down Expand Up @@ -145,6 +146,26 @@ public void setType(AccountType type)
this.type = type;
}

public String getDescription()
{
return description;
}

public void setDescription(String description)
{
this.description = description;
}

public LocalDate getEndDate()
{
return endDate;
}

public void setEndDate(LocalDate endDate)
{
this.endDate = endDate;
}

@Override
public Icon getIconReference()
{
Expand Down Expand Up @@ -186,6 +207,16 @@ public String getDefaultFontColor(boolean isDarkTheme)
return FONT_COLOR_LIGHT_THEME;
}

public Long getRemainingDays()
{
if(this.endDate == null)
{
return null;
}

return LocalDate.now().until(this.endDate, ChronoUnit.DAYS);
}

@Override
public String toString()
{
Expand All @@ -198,6 +229,8 @@ public String toString()
", accountState=" + accountState +
", type=" + type +
", iconReference=" + iconReference +
", description='" + description + '\'' +
", endDate=" + endDate +
'}';
}

Expand All @@ -213,12 +246,14 @@ public boolean equals(Object o)
Objects.equals(isDefault, account.isDefault) &&
accountState == account.accountState &&
Objects.equals(iconReference, account.iconReference) &&
type == account.type;
type == account.type &&
Objects.equals(description, account.description) &&
Objects.equals(endDate, account.endDate);
}

@Override
public int hashCode()
{
return Objects.hash(ID, name, isSelected, isDefault, accountState, iconReference, type);
return Objects.hash(ID, name, description, isSelected, isDefault, accountState, iconReference, type, endDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.deadlocker8.budgetmaster.controller.BaseController;
import de.deadlocker8.budgetmaster.icon.IconService;
import de.deadlocker8.budgetmaster.settings.SettingsService;
import de.deadlocker8.budgetmaster.utils.FontAwesomeIcons;
import de.deadlocker8.budgetmaster.utils.Mappings;
import de.deadlocker8.budgetmaster.utils.ResourceNotFoundException;
Expand All @@ -19,7 +20,9 @@
import org.springframework.web.context.request.WebRequest;

import jakarta.servlet.http.HttpServletRequest;

import java.text.MessageFormat;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

Expand All @@ -39,6 +42,7 @@ private static class ModelAttributes
public static final String FONTAWESOME_ICONS = "fontawesomeIcons";
public static final String ERROR = "error";
public static final String NOTIFICATIONS = "notifications";
public static final String TODAY = "today";
}

private static class ReturnValues
Expand All @@ -55,12 +59,14 @@ private static class ReturnValues

private final AccountService accountService;
private final IconService iconService;
private final SettingsService settingsService;

@Autowired
public AccountController(AccountService accountService, IconService iconService)
public AccountController(AccountService accountService, IconService iconService, SettingsService settingsService)
{
this.accountService = accountService;
this.iconService = iconService;
this.settingsService = settingsService;
}

@GetMapping(value = "/{ID}/select")
Expand Down Expand Up @@ -148,6 +154,7 @@ public String newAccount(Model model)
model.addAttribute(ModelAttributes.ONE_ENTITY, emptyAccount);
model.addAttribute(ModelAttributes.AVAILABLE_ACCOUNT_STATES, AccountState.values());
model.addAttribute(ModelAttributes.FONTAWESOME_ICONS, FontAwesomeIcons.ICONS);
model.addAttribute(ModelAttributes.TODAY, LocalDate.now());
return ReturnValues.NEW_ENTITY;
}

Expand All @@ -163,6 +170,7 @@ public String editAccount(Model model, @PathVariable("ID") Integer ID)
model.addAttribute(ModelAttributes.ONE_ENTITY, accountOptional.get());
model.addAttribute(ModelAttributes.AVAILABLE_ACCOUNT_STATES, AccountState.values());
model.addAttribute(ModelAttributes.FONTAWESOME_ICONS, FontAwesomeIcons.ICONS);
model.addAttribute(ModelAttributes.TODAY, LocalDate.now());
return ReturnValues.NEW_ENTITY;
}

Expand Down Expand Up @@ -211,6 +219,7 @@ public String post(HttpServletRequest request, WebRequest webRequest, Model mode
model.addAttribute(ModelAttributes.ONE_ENTITY, account);
model.addAttribute(ModelAttributes.AVAILABLE_ACCOUNT_STATES, AccountState.values());
model.addAttribute(ModelAttributes.FONTAWESOME_ICONS, FontAwesomeIcons.ICONS);
model.addAttribute(ModelAttributes.TODAY, LocalDate.now());
return ReturnValues.NEW_ENTITY;
}

Expand Down Expand Up @@ -256,4 +265,11 @@ public String globalAccountSelectModal(Model model)

return ReturnValues.GLOBAL_ACCOUNT_SELECT_MODAL;
}

@GetMapping("/cancelReminder")
public String cancelReminder(HttpServletRequest request)
{
settingsService.updateLastAccountEndDateReminderDate();
return "redirect:" + request.getHeader("Referer");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ public void createDefaults()
{
if(accountRepository.findAll().isEmpty())
{
Account placeholder = new Account("Placeholder", AccountType.ALL);
Account placeholder = new Account("Placeholder", "", AccountType.ALL, null);
final Icon newIcon = iconService.createIconReference(null, PLACEHOLDER_ICON, null);
iconService.getRepository().save(newIcon);
placeholder.setIconReference(newIcon);
accountRepository.save(placeholder);
LOGGER.debug("Created placeholder account");

Account account = accountRepository.save(new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), AccountType.CUSTOM));
Account account = accountRepository.save(new Account(Localization.getString(Strings.ACCOUNT_DEFAULT_NAME), "", AccountType.CUSTOM, null));
final Icon iconDefaultAccount = iconService.createIconReference(null, null, null);
iconService.getRepository().save(iconDefaultAccount);
account.setIconReference(iconDefaultAccount);
Expand Down Expand Up @@ -184,6 +184,7 @@ private void updateMissingAttributes()
for(Account account : accountRepository.findAll())
{
handleNullValuesForAccountState(account);
handleNullValuesDescription(account);
accountRepository.save(account);
}
}
Expand All @@ -193,7 +194,16 @@ private void handleNullValuesForAccountState(Account account)
if(account.getAccountState() == null)
{
account.setAccountState(AccountState.FULL_ACCESS);
LOGGER.debug(MessageFormat.format("Updated account {0}: Set missing attribute \"accountState\" to {1}", account.getName(), account.getAccountState()));
LOGGER.debug(MessageFormat.format("Updated account {0}: Set missing attribute \"accountState\" to \"{1}\"", account.getName(), account.getAccountState()));
}
}

private void handleNullValuesDescription(Account account)
{
if(account.getDescription() == null)
{
account.setDescription("");
LOGGER.debug(MessageFormat.format("Updated account {0}: Set missing attribute \"description\" to {1}", account.getName(), account.getDescription()));
}
}

Expand Down Expand Up @@ -273,9 +283,11 @@ public void updateExistingAccount(Account newAccount)

Account existingAccount = existingAccountOptional.get();
existingAccount.setName(newAccount.getName());
existingAccount.setDescription(newAccount.getDescription());
existingAccount.setIconReference(newAccount.getIconReference());
existingAccount.setType(AccountType.CUSTOM);
existingAccount.setAccountState(newAccount.getAccountState());
existingAccount.setEndDate(newAccount.getEndDate());
accountRepository.save(existingAccount);

if(existingAccount.isDefault() && existingAccount.getAccountState() != AccountState.FULL_ACCESS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public String index(Model model)
public String whatsNewModal(Model model)
{
final List<NewsEntry> newsEntries = new ArrayList<>();
newsEntries.add(NewsEntry.createWithLocalizationKey("mariaDB"));
newsEntries.add(NewsEntry.createWithLocalizationKey("accountEndDate"));
newsEntries.add(NewsEntry.createWithLocalizationKey("accountDescription"));
newsEntries.add(NewsEntry.createWithLocalizationKey("transactionNameSuggestionsSort"));
newsEntries.add(NewsEntry.createWithLocalizationKey("transactionNameSuggestionsSort"));

model.addAttribute(ModelAttributes.NEWS_ENTRIES, newsEntries);
return ReturnValues.WHATS_NEW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@

import java.text.MessageFormat;

public class NewsEntry
public record NewsEntry(String headline, String description)
{
private final String headline;
private final String description;

public NewsEntry(String headline, String description)
{
this.headline = headline;
this.description = description;
}

public static NewsEntry createWithLocalizationKey(String shortKey)
{
return createWithLocalizationKeys(MessageFormat.format("news.{0}.headline", shortKey),
Expand All @@ -26,15 +17,6 @@ public static NewsEntry createWithLocalizationKeys(String headlineKey, String de
return new NewsEntry(Localization.getString(headlineKey), Localization.getString(descriptionKey));
}

public String getHeadline()
{
return headline;
}

public String getDescription()
{
return description;
}

@Override
public String toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gson.JsonParser;
import de.deadlocker8.budgetmaster.database.model.BackupDatabase;
import de.deadlocker8.budgetmaster.database.model.v10.BackupDatabase_v10;
import de.deadlocker8.budgetmaster.database.model.v11.BackupDatabase_v11;
import de.deadlocker8.budgetmaster.database.model.v4.BackupDatabase_v4;
import de.deadlocker8.budgetmaster.database.model.v5.BackupDatabase_v5;
import de.deadlocker8.budgetmaster.database.model.v6.BackupDatabase_v6;
Expand All @@ -21,7 +22,7 @@ public class DatabaseParser
final Logger LOGGER = LoggerFactory.getLogger(this.getClass());

private static final int MINIMUM_VERSION = 4;
public static final int LATEST_VERSION = 10;
public static final int LATEST_VERSION = 11;

private final String jsonString;

Expand Down Expand Up @@ -90,6 +91,13 @@ public InternalDatabase parseDatabaseFromJSON() throws IllegalArgumentException
importedDatabase = parsedDatabase;
}

if(version == 11)
{
BackupDatabase_v11 parsedDatabase = new DatabaseParser_v11(jsonString).parseDatabaseFromJSON();
LOGGER.debug(MessageFormat.format("Parsed database with {0} transactions, {1} categories, {2} accounts, {3} templates {4} charts {5} images {6} icons and {7} transaction name keywords", parsedDatabase.getTransactions().size(), parsedDatabase.getCategories().size(), parsedDatabase.getAccounts().size(), parsedDatabase.getTemplates().size(), parsedDatabase.getCharts().size(), parsedDatabase.getImages().size(), parsedDatabase.getIcons().size(), parsedDatabase.getTransactionNameKeywords().size()));
importedDatabase = parsedDatabase;
}

if(importedDatabase == null)
{
throw new IllegalArgumentException(Localization.getString("error.database.import.unknown.version"));
Expand Down
Loading

0 comments on commit 39998ba

Please sign in to comment.