use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class ReturnOfCapitalSlipController method buildTransaction.
@NotNull
@Override
public Transaction buildTransaction() {
BigDecimal incomeExchangedAmount = decimalTextField.getDecimal().negate();
BigDecimal accountExchangedAmount = decimalTextField.getDecimal();
if (!incomeExchangePane.getSelectedAccount().getCurrencyNode().equals(accountProperty().get().getCurrencyNode())) {
incomeExchangedAmount = incomeExchangePane.exchangeAmountProperty().get().negate();
}
if (!accountExchangePane.getSelectedAccount().getCurrencyNode().equals(accountProperty().get().getCurrencyNode())) {
accountExchangedAmount = accountExchangePane.exchangeAmountProperty().get();
}
final Transaction transaction = TransactionFactory.generateRocXTransaction(incomeExchangePane.getSelectedAccount(), accountProperty().get(), accountExchangePane.getSelectedAccount(), securityComboBox.getValue(), decimalTextField.getDecimal(), incomeExchangedAmount, accountExchangedAmount, datePicker.getValue(), memoTextField.getText());
transaction.setNumber(numberComboBox.getValue());
return transaction;
}
use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class SellShareSlipController method buildTransaction.
@NotNull
@Override
public Transaction buildTransaction() {
final BigDecimal exchangeRate = accountExchangePane.getExchangeRate();
final List<TransactionEntry> gains = gainLossPane.getTransactions();
final List<TransactionEntry> fees = feePane.getTransactions();
final Transaction transaction = TransactionFactory.generateSellXTransaction(accountExchangePane.getSelectedAccount(), accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), exchangeRate, datePicker.getValue(), memoTextField.getText(), fees, gains);
transaction.setNumber(numberComboBox.getValue());
return attachmentPane.buildTransaction(transaction);
}
use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class AbstractRegisterPanel method jumpAction.
/**
* Displays a register dialog for the opposite account and places the opposite side of the transaction in edit mode.
*/
void jumpAction() {
Transaction t = getSelectedTransaction();
if (t != null) {
if (t.getTransactionType() == TransactionType.DOUBLEENTRY) {
final Set<Account> set = t.getAccounts();
set.stream().filter(a -> !getAccount().equals(a)).forEach(a -> RegisterFrame.showDialog(a, t));
} else if (t.getTransactionType() == TransactionType.SPLITENTRY) {
final Account common = t.getCommonAccount();
if (!getAccount().equals(common)) {
RegisterFrame.showDialog(common, t);
}
} else if (t instanceof InvestmentTransaction) {
final Account invest = ((InvestmentTransaction) t).getInvestmentAccount();
if (!getAccount().equals(invest)) {
RegisterFrame.showDialog(invest, t);
}
}
}
}
use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class AbstractReconcileTableModel method messagePosted.
@Override
public void messagePosted(final Message event) {
if (event.getObject(MessageProperty.ACCOUNT).equals(account)) {
rwl.writeLock().lock();
try {
final Transaction transaction = event.getObject(MessageProperty.TRANSACTION);
EventQueue.invokeLater(() -> {
switch(event.getEvent()) {
case TRANSACTION_REMOVE:
RecTransaction trans = findTransaction(transaction);
if (trans != null) {
int index = list.indexOf(trans);
list.remove(index);
fireTableRowsDeleted(index, index);
}
break;
case TRANSACTION_ADD:
if (isVisible(transaction)) {
RecTransaction newTran = new RecTransaction(transaction, transaction.getReconciled(account));
int index = Collections.binarySearch(list, newTran);
if (index < 0) {
index = -index - 1;
list.add(index, newTran);
fireTableRowsInserted(index, index);
}
}
break;
default:
break;
}
});
} finally {
rwl.writeLock().unlock();
}
}
}
use of jgnash.engine.Transaction in project jgnash by ccavanaugh.
the class AbstractBankTransactionPanel method enterAction.
/**
* Method that is called when the enter button is used
*/
@Override
public void enterAction() {
if (validateForm()) {
if (modTrans == null) {
Transaction newTrans = buildTransaction();
ReconcileManager.reconcileTransaction(getAccount(), newTrans, getReconciledState());
// chain the transaction build
newTrans = attachmentPanel.buildTransaction(newTrans);
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
if (engine != null) {
engine.addTransaction(newTrans);
}
} else {
Transaction newTrans = buildTransaction();
// restore the reconciled state of the previous old transaction
for (Account a : modTrans.getAccounts()) {
if (!a.equals(getAccount())) {
ReconcileManager.reconcileTransaction(a, newTrans, modTrans.getReconciled(a));
}
}
/*
* Reconcile the modified transaction for this account.
* This must be performed last to ensure consistent results per the ReconcileManager rules
*/
ReconcileManager.reconcileTransaction(getAccount(), newTrans, getReconciledState());
// chain the transaction build
newTrans = attachmentPanel.buildTransaction(newTrans);
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
if (engine != null && engine.removeTransaction(modTrans)) {
engine.addTransaction(newTrans);
}
}
clearForm();
fireOkAction();
focusFirstComponent();
}
}
Aggregations