@FXML
  private void handleDeleteAccountAction() {
    if (getSelectedAccount().isPresent()) {
      final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
      Objects.requireNonNull(engine);

      if (!engine.removeAccount(getSelectedAccount().get())) {
        StaticUIMethods.displayError(resources.getString("Message.Error.AccountRemove"));
      }
    }
  }
  private void loadAccountTree() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);

    if (engine != null) {
      RootAccount r = engine.getRootAccount();

      final TreeItem<Account> root = new TreeItem<>(r);
      root.setExpanded(true);

      treeTableView.setRoot(root);
      loadChildren(root);
    } else {
      treeTableView.setRoot(null);
    }
  }
  private void updateAccountCode(final Account account, final Integer code) {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);

    if (engine != null) {
      try {
        final Account template = (Account) account.clone();
        template.setAccountCode(code);

        engine.modifyAccount(template, account);
      } catch (final CloneNotSupportedException e) {
        Logger.getLogger(AccountsViewController.class.getName())
            .log(Level.SEVERE, e.getLocalizedMessage(), e);
      }
    }
  }
  @FXML
  private void convertAction() {
    final Optional<Account> accountOptional =
        StaticAccountsMethods.selectAccount(null, accountProperty.get());
    if (accountOptional.isPresent()) {
      final Account opp = accountOptional.get();

      final Transaction t = new Transaction();

      t.setDate(datePicker.getValue());
      t.setNumber(numberComboBox.getValue());
      t.setPayee(payeeTextField.getText());

      final TransactionEntry entry = new TransactionEntry();
      entry.setMemo(memoTextField.getText());

      if (amountField.getDecimal().signum() >= 0) {
        entry.setCreditAccount(accountProperty.get());
        entry.setDebitAccount(opp);
      } else {
        entry.setDebitAccount(accountProperty.get());
        entry.setCreditAccount(opp);
      }

      entry.setCreditAmount(amountField.getDecimal().abs());
      entry.setDebitAmount(amountField.getDecimal().abs().negate());

      t.addTransactionEntry(entry);

      ReconcileManager.reconcileTransaction(accountProperty.get(), t, getReconciledState());

      TransactionDialog.showAndWait(
          accountProperty.get(),
          t,
          optional -> {
            if (optional.isPresent()) {
              final Transaction tran = optional.get();
              final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
              Objects.requireNonNull(engine);

              if (engine.removeTransaction(modTrans)) {
                engine.addTransaction(tran);
              }
              clearForm();
            }
          });
    }
  }