Skip to content

Commit

Permalink
#764 - add new settings option to enable/disable account end date rem…
Browse files Browse the repository at this point in the history
…inders
  • Loading branch information
deadlocker8 committed Oct 1, 2024
1 parent e0b15e4 commit 4a9dd3e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public class Settings

private Boolean orderTransactionNameSuggestionsAlphabetically;

private Boolean accountEndDateReminderActivated;
@DateTimeFormat(pattern = "dd.MM.yyyy")
private LocalDate lastAccountEndDateReminderDate;

public Settings()
{
// empty
Expand Down Expand Up @@ -76,6 +80,8 @@ public static Settings getDefault()
defaultSettings.setWhatsNewShownForCurrentVersion(false);
defaultSettings.setMigrationDeclined(false);
defaultSettings.setOrderTransactionNameSuggestionsAlphabetically(true);
defaultSettings.setAccountEndDateReminderActivated(true);
defaultSettings.setLastAccountEndDateReminderDate(LocalDate.now());

return defaultSettings;
}
Expand Down Expand Up @@ -314,6 +320,26 @@ public void setOrderTransactionNameSuggestionsAlphabetically(Boolean orderTransa
this.orderTransactionNameSuggestionsAlphabetically = orderTransactionNameSuggestionsAlphabetically;
}

public Boolean getAccountEndDateReminderActivated()
{
return accountEndDateReminderActivated;
}

public void setAccountEndDateReminderActivated(Boolean accountEndDateReminderActivated)
{
this.accountEndDateReminderActivated = accountEndDateReminderActivated;
}

public LocalDate getLastAccountEndDateReminderDate()
{
return lastAccountEndDateReminderDate;
}

public void setLastAccountEndDateReminderDate(LocalDate lastAccountEndDateReminderDate)
{
this.lastAccountEndDateReminderDate = lastAccountEndDateReminderDate;
}

@Override
public String toString()
{
Expand All @@ -340,6 +366,8 @@ public String toString()
", whatsNewShownForCurrentVersion=" + whatsNewShownForCurrentVersion +
", migrationDeclined=" + migrationDeclined +
", orderTransactionNameSuggestionsAlphabetically=" + orderTransactionNameSuggestionsAlphabetically +
", accountEndDateReminderActivated=" + accountEndDateReminderActivated +
", lastAccountEndDateReminderDate=" + lastAccountEndDateReminderDate +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.transaction.annotation.Transactional;

import jakarta.annotation.PostConstruct;

import java.lang.reflect.Field;
import java.util.NoSuchElementException;
import java.util.Optional;
Expand Down Expand Up @@ -116,6 +117,14 @@ public void createDefaultSettingsIfNotExists()
{
settings.setOrderTransactionNameSuggestionsAlphabetically(defaultSettings.getOrderTransactionNameSuggestionsAlphabetically());
}
if(settings.getAccountEndDateReminderActivated() == null)
{
settings.setAccountEndDateReminderActivated(defaultSettings.getAccountEndDateReminderActivated());
}
if(settings.getLastAccountEndDateReminderDate() == null)
{
settings.setLastAccountEndDateReminderDate(defaultSettings.getLastAccountEndDateReminderDate());
}

settingsRepository.save(settings);
}
Expand All @@ -139,6 +148,13 @@ public void updateMigrationDeclined(boolean isDeclined)
settings.setMigrationDeclined(isDeclined);
}

@Transactional
public void updateLastAccountEndDateReminderDate()
{
Settings settings = getSettings();
settings.setLastAccountEndDateReminderDate(DateHelper.getCurrentDate());
}

@Transactional
public void updateSettings(Settings newSettings)
{
Expand Down

0 comments on commit 4a9dd3e

Please sign in to comment.