Added all currencies to account edit page.

This commit is contained in:
Andrew Lalis 2023-12-28 21:44:17 -05:00
parent e09e36527f
commit 633cd60572
1 changed files with 14 additions and 11 deletions

View File

@ -12,8 +12,8 @@ import javafx.scene.control.*;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Currency; import java.util.*;
import java.util.Optional; import java.util.stream.Stream;
import static com.andrewlalis.perfin.PerfinApp.router; import static com.andrewlalis.perfin.PerfinApp.router;
@ -38,15 +38,18 @@ public class EditAccountController implements RouteSelectionListener {
@FXML @FXML
public void initialize() { public void initialize() {
final String[] currencies = { List<Currency> priorityCurrencies = Stream.of("USD", "EUR", "GBP", "CAD", "AUD")
"USD", .map(Currency::getInstance)
"EUR", .toList();
"GBP" List<Currency> availableCurrencies = Currency.getAvailableCurrencies().stream()
}; .filter(c -> !priorityCurrencies.contains(c))
for (String currencyCode : currencies) { .sorted(Comparator.comparing(Currency::getCurrencyCode))
accountCurrencyComboBox.getItems().add(Currency.getInstance(currencyCode)); .toList();
} List<Currency> allCurrencies = new ArrayList<>();
accountCurrencyComboBox.getSelectionModel().select(Currency.getInstance("USD")); allCurrencies.addAll(priorityCurrencies);
allCurrencies.addAll(availableCurrencies);
accountCurrencyComboBox.getItems().addAll(allCurrencies);
accountCurrencyComboBox.getSelectionModel().selectFirst();
accountTypeChoiceBox.getItems().add(AccountType.CHECKING); accountTypeChoiceBox.getItems().add(AccountType.CHECKING);
accountTypeChoiceBox.getItems().add(AccountType.SAVINGS); accountTypeChoiceBox.getItems().add(AccountType.SAVINGS);