Skip to content

Commit

Permalink
fix filename after saved month is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
mathisdt committed Oct 31, 2024
1 parent c74e3ac commit dae6f7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public class AccountMonth implements Comparable<AccountMonth> {
private String account;
private YearMonth yearMonth;

public String getAccountForFilename() {
return account.replaceAll("[^a-zA-Z0-9]", "_").replaceAll("__", "_");
}

public String getFilename() {
return account + "-" + YEAR_MONTH_FORMAT.format(yearMonth) + ".json";
}
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/org/zephyrsoft/optigemspoonfeeder/ui/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ private static List<YearMonth> availableMonths() {
private void applyRulesToParsedData() {
convertParsedData();

updateDownloadButtons();

updateFooter();
}

private void updateDownloadButtons() {
buttons.removeAll();

StreamResource streamBuchungen = new StreamResource(
Expand All @@ -336,8 +342,6 @@ private void applyRulesToParsedData() {
downloadRestMt940.add(new Button("Rest (MT940)", new Icon(VaadinIcon.DOWNLOAD)));

buttons.add(downloadBuchungen, downloadRestMt940);

updateFooter();
}

private void parseUploadedFile(InputStream inputStream, String filename) {
Expand Down Expand Up @@ -385,6 +389,9 @@ private void loadStoredMonth(AccountMonth accountMonth) {
logArea.setText(accountMonth.getLabel() +" geladen\n" + result.getLogMessages());
updateFooter();
loadedMonth = accountMonth;
originalFilename = accountMonth.getAccountForFilename() + "_" + MONTH_FORMAT.format(accountMonth.getYearMonth()) + ".hibiscus";
timestamp = TIMESTAMP_FORMAT.format(LocalDateTime.now());
updateDownloadButtons();

grid.removeAllColumns();
grid.setItems(new ListDataProvider<>(result.getResults()));
Expand Down

0 comments on commit dae6f7b

Please sign in to comment.