use of jgnash.engine.InvestmentTransaction in project jgnash by ccavanaugh.
the class BuyShareSlipController method modifyTransaction.
@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
if (transaction.getTransactionType() != TransactionType.BUYSHARE || !(transaction instanceof InvestmentTransaction)) {
throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
}
clearForm();
datePicker.setValue(transaction.getLocalDate());
numberComboBox.setValue(transaction.getNumber());
List<TransactionEntry> entries = transaction.getTransactionEntries();
feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
entries.stream().filter(e -> e instanceof TransactionEntryBuyX).forEach(e -> {
final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoTextField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityComboBox.setSecurityNode(entry.getSecurityNode());
if (entry.getCreditAccount().equals(accountProperty().get())) {
accountExchangePane.setSelectedAccount(entry.getDebitAccount());
accountExchangePane.setExchangedAmount(entry.getDebitAmount().abs());
} else {
accountExchangePane.setSelectedAccount(entry.getCreditAccount());
accountExchangePane.setExchangedAmount(entry.getCreditAmount());
}
});
modTrans = transaction;
modTrans = attachmentPane.modifyTransaction(modTrans);
setReconciledState(transaction.getReconciled(accountProperty().get()));
}
use of jgnash.engine.InvestmentTransaction in project jgnash by ccavanaugh.
the class RegisterTableController method handleJumpAction.
void handleJumpAction() {
Transaction t = selectedTransaction.get();
if (t != null) {
if (t.getTransactionType() == TransactionType.DOUBLEENTRY) {
final Set<Account> set = t.getAccounts();
set.stream().filter(a -> !account.get().equals(a)).forEach(a -> RegisterStage.getRegisterStage(a).show(t));
} else if (t.getTransactionType() == TransactionType.SPLITENTRY) {
final Account common = t.getCommonAccount();
if (!account.get().equals(common)) {
RegisterStage.getRegisterStage(common).show(t);
}
} else if (t instanceof InvestmentTransaction) {
final Account invest = ((InvestmentTransaction) t).getInvestmentAccount();
if (!account.get().equals(invest)) {
RegisterStage.getRegisterStage(invest).show(t);
}
}
}
}
use of jgnash.engine.InvestmentTransaction in project jgnash by ccavanaugh.
the class SlipController method newTransaction.
private void newTransaction(final Transaction t) {
clearForm();
amountField.setDecimal(t.getAmount(accountProperty().get()).abs());
// Must consider if this is a concatenated memo to set the field correctly
memoTextField.setText(t.isMemoConcatenated() ? t.getMemo() : t.getTransactionMemo());
payeeTextField.setText(t.getPayee());
numberComboBox.setValue(t.getNumber());
datePicker.setValue(t.getLocalDate());
setReconciledState(t.getReconciled(accountProperty().get()));
if (t.getTransactionType() == TransactionType.SPLITENTRY) {
if (canModifyTransaction(t)) {
// split common account is the same as the base account
// clone the splits for modification
transactionEntries.clear();
for (final TransactionEntry entry : t.getTransactionEntries()) {
try {
transactionEntries.add((TransactionEntry) entry.clone());
} catch (final CloneNotSupportedException e) {
Logger.getLogger(SlipController.class.getName()).log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
amountField.setDecimal(t.getAmount(accountProperty().get()).abs());
} else {
// not the same common account, can only modify the entry
splitsButton.setDisable(true);
payeeTextField.setEditable(false);
numberComboBox.setDisable(true);
datePicker.setEditable(false);
// Override
memoTextField.setText(t.getMemo(account.get()));
amountField.setDecimal(t.getAmount(accountProperty().get()).abs());
for (final TransactionEntry entry : t.getTransactionEntries()) {
if (entry.getCreditAccount() == accountProperty().get()) {
accountExchangePane.setExchangedAmount(entry.getDebitAmount().abs());
break;
} else if (entry.getDebitAccount() == accountProperty().get()) {
accountExchangePane.setExchangedAmount(entry.getCreditAmount());
break;
}
}
}
} else if (t instanceof InvestmentTransaction) {
Logger logger = Logger.getLogger(SlipController.class.getName());
logger.warning("unsupported transaction type");
} else {
// DoubleEntryTransaction
datePicker.setEditable(true);
}
// setup the accountCombo correctly
if (t.getTransactionType() == TransactionType.DOUBLEENTRY) {
TransactionEntry entry = t.getTransactionEntries().get(0);
if (slipType == SlipType.DECREASE) {
accountExchangePane.setSelectedAccount(entry.getCreditAccount());
accountExchangePane.setExchangedAmount(entry.getCreditAmount());
} else {
accountExchangePane.setSelectedAccount(entry.getDebitAccount());
accountExchangePane.setExchangedAmount(entry.getDebitAmount().abs());
}
}
}
use of jgnash.engine.InvestmentTransaction in project jgnash by ccavanaugh.
the class ReinvestDividendSlipController method modifyTransaction.
@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
if (!(transaction instanceof InvestmentTransaction) || transaction.getTransactionType() != TransactionType.REINVESTDIV) {
throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
}
clearForm();
datePicker.setValue(transaction.getLocalDate());
numberComboBox.setValue(transaction.getNumber());
feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
gainLossPane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentGainLossEntries());
transaction.getTransactionEntries().stream().filter(e -> e instanceof TransactionEntryReinvestDivX).forEach(e -> {
final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoTextField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityComboBox.setSecurityNode(entry.getSecurityNode());
});
modTrans = transaction;
modTrans = attachmentPane.modifyTransaction(modTrans);
setReconciledState(transaction.getReconciled(accountProperty().get()));
}
use of jgnash.engine.InvestmentTransaction in project jgnash by ccavanaugh.
the class SellShareSlipController method modifyTransaction.
@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
if (!(transaction instanceof InvestmentTransaction) || transaction.getTransactionType() != TransactionType.SELLSHARE) {
throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
}
clearForm();
datePicker.setValue(transaction.getLocalDate());
numberComboBox.setValue(transaction.getNumber());
feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
gainLossPane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentGainLossEntries());
transaction.getTransactionEntries().stream().filter(e -> e instanceof TransactionEntrySellX).forEach(e -> {
final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoTextField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityComboBox.setSecurityNode(entry.getSecurityNode());
if (entry.getCreditAccount().equals(accountProperty().get())) {
accountExchangePane.setSelectedAccount(entry.getDebitAccount());
accountExchangePane.setExchangedAmount(entry.getDebitAmount().abs());
} else {
Logger.getLogger(SellShareSlipController.class.getName()).warning("was not expected");
}
});
modTrans = transaction;
modTrans = attachmentPane.modifyTransaction(modTrans);
setReconciledState(transaction.getReconciled(accountProperty().get()));
}
Aggregations