use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class RecurringEntryDialog method editTransactionAction.
private void editTransactionAction() {
Transaction t = TransactionDialog.showDialog(accountCombo.getSelectedAccount(), transaction);
if (t != null) {
transaction = t;
transactionField.setText(transaction.getPayee());
}
}
use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class AbstractBankTransactionPanel method modifyTransactionForAutoComplete.
/**
* Modify a transaction before it is used to complete the panel for auto fill. The supplied transaction must be a
* new or cloned transaction. It can't be a transaction that lives in the map. The returned transaction can be the
* supplied reference or may be a new instance
*
* @param t The transaction to modify
* @return the modified transaction
*/
private Transaction modifyTransactionForAutoComplete(final Transaction t) {
// tweak the transaction
t.setNumber(null);
// clear both sides
t.setReconciled(ReconciledState.NOT_RECONCILED);
// set the last date as required
if (!getRememberLastDate()) {
t.setDate(LocalDate.now());
} else {
t.setDate(datePanel.getLocalDate());
}
// preserve any transaction entries that may have been entered first
if (!amountField.isEmpty() && !amountField.getText().isEmpty()) {
Transaction newTrans = buildTransaction();
t.clearTransactionEntries();
t.addTransactionEntries(newTrans.getTransactionEntries());
}
// preserve any preexisting memo field info
if (memoField.getText() != null && !memoField.getText().isEmpty()) {
t.setMemo(memoField.getText());
}
// Do not copy over attachments
t.setAttachment(null);
return t;
}
use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class AbstractRegisterPanel method messagePosted.
@Override
public void messagePosted(final Message event) {
final Account account = getAccount();
// must update on EDT or a deadlock can occur
EventQueue.invokeLater(() -> {
Account a = event.getObject(MessageProperty.ACCOUNT);
if (account.equals(a)) {
switch(event.getEvent()) {
case ACCOUNT_MODIFY:
updateAccountState();
updateAccountInfo();
break;
case TRANSACTION_ADD:
final Transaction t = event.getObject(MessageProperty.TRANSACTION);
final int index = account.indexOf(t);
if (index == account.getTransactionCount() - 1) {
autoScroll();
}
setSelectedTransaction(t);
updateAccountInfo();
break;
case TRANSACTION_REMOVE:
updateAccountInfo();
break;
default:
break;
}
}
if (event.getEvent() == ChannelEvent.SECURITY_HISTORY_ADD || event.getEvent() == ChannelEvent.SECURITY_HISTORY_REMOVE) {
SecurityNode node = event.getObject(MessageProperty.COMMODITY);
if (account.containsSecurity(node)) {
updateAccountInfo();
}
}
});
}
use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class AbstractRegisterPanel method reconcileAction.
private void reconcileAction(final ReconciledState reconciled) {
final Transaction t = getSelectedTransaction();
if (t != null) {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
engine.setTransactionReconciled(t, getAccount(), reconciled);
}
}
use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class ImportPageTwoController method getSettings.
@Override
public void getSettings(final Map<ImportWizard.Settings, Object> map) {
@SuppressWarnings("unchecked") final ImportBank<ImportTransaction> bank = (ImportBank<ImportTransaction>) map.get(ImportWizard.Settings.BANK);
if (bank != null) {
final List<ImportTransaction> list = bank.getTransactions();
baseAccount = (Account) map.get(ImportWizard.Settings.ACCOUNT);
final CurrencyNode currencyNode = baseAccount.getCurrencyNode();
// rescale for consistency
numberFormat.setMinimumFractionDigits(currencyNode.getScale());
numberFormat.setMaximumFractionDigits(currencyNode.getScale());
// List of enabled import filters
final List<ImportFilter> importFilterList = ImportFilter.getEnabledImportFilters();
// set to sane account assuming it's going to be a single entry
for (final ImportTransaction t : list) {
// Process transactions with the import filter
for (final ImportFilter importFilter : importFilterList) {
t.setMemo(importFilter.processMemo(t.getMemo()));
t.setPayee(importFilter.processPayee(t.getPayee()));
}
if (t.getTransactionType() != TransactionType.REINVESTDIV) {
t.setAccount(baseAccount);
}
if (t.isInvestmentTransaction()) {
switch(t.getTransactionType()) {
case BUYSHARE:
t.setFeesAccount(baseAccount);
break;
case SELLSHARE:
t.setFeesAccount(baseAccount);
t.setGainsAccount(baseAccount);
break;
case DIVIDEND:
t.setGainsAccount(baseAccount);
break;
case REINVESTDIV:
t.setFeesAccount(baseAccount);
t.setGainsAccount(baseAccount);
break;
default:
}
}
// force reset
t.setState(ImportState.NEW);
}
incomeAccountColumn.setVisible(bank.isInvestmentAccount());
expenseAccountColumn.setVisible(bank.isInvestmentAccount());
typeColumn.setVisible(bank.isInvestmentAccount());
// match up any pre-existing transactions
GenericImport.matchTransactions(list, baseAccount);
// classify the transactions
if (Options.globalBayesProperty().get()) {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
final List<Transaction> transactions = engine.getTransactions();
transactions.sort(null);
BayesImportClassifier.classifyTransactions(list, transactions, baseAccount);
} else {
BayesImportClassifier.classifyTransactions(list, baseAccount.getSortedTransactionList(), baseAccount);
}
tableView.getItems().setAll(list);
FXCollections.sort(tableView.getItems());
tableViewManager.restoreLayout();
}
Platform.runLater(tableViewManager::packTable);
updateDescriptor();
}
Aggregations