use of jgnash.engine.InvestmentTransaction in project jgnash by ccavanaugh.
the class InvestmentTransactionQuantityTableCell method updateItem.
@Override
protected void updateItem(final BigDecimal amount, final boolean empty) {
// required
super.updateItem(amount, empty);
if (!empty && amount != null && getTableRow() != null) {
final Transaction transaction = (Transaction) getTableRow().getItem();
if (transaction instanceof InvestmentTransaction) {
final NumberFormat format = CommodityFormat.getShortNumberFormat(((InvestmentTransaction) transaction).getSecurityNode());
applyFormat(amount, format);
} else {
setText(null);
}
} else {
setText(null);
}
}
use of jgnash.engine.InvestmentTransaction in project jgnash by ccavanaugh.
the class OfxExport method writeInvestmentTransactions.
/**
* Writes all investment account transactions within the date range
*/
private void writeInvestmentTransactions() {
for (final Transaction transaction : account.getTransactions(startDate, endDate)) {
if (transaction instanceof InvestmentTransaction) {
final InvestmentTransaction invTransaction = (InvestmentTransaction) transaction;
switch(invTransaction.getTransactionType()) {
case ADDSHARE:
case BUYSHARE:
writeBuyStockTransaction(invTransaction);
break;
case REMOVESHARE:
case SELLSHARE:
writeSellStockTransaction(invTransaction);
break;
case DIVIDEND:
writeDividendTransaction(invTransaction);
break;
case REINVESTDIV:
writeReinvestStockTransaction(invTransaction);
break;
default:
break;
}
} else {
// bank transaction, write it
indentedWriter.println(wrapOpen(INVBANKTRAN), indentLevel++);
writeBankTransaction(transaction);
indentedWriter.println(wrapClose(INVBANKTRAN), --indentLevel);
}
}
}
use of jgnash.engine.InvestmentTransaction in project jgnash by ccavanaugh.
the class RegisterActions method duplicateTransaction.
static void duplicateTransaction(final Account account, final List<Transaction> transactions) {
final ResourceBundle resourceBundle = ResourceUtils.getBundle();
final String eftNumber = resourceBundle.getString("Item.EFT");
for (final Transaction transaction : transactions) {
try {
final Transaction clone = (Transaction) transaction.clone();
clone.setDate(LocalDate.now());
if (!clone.getNumber().isEmpty() && !clone.getNumber().equals(eftNumber)) {
// may return an empty string
final String nextTransactionNumber = account.getNextTransactionNumber();
if (!nextTransactionNumber.isEmpty()) {
clone.setNumber(nextTransactionNumber);
}
}
if (transaction instanceof InvestmentTransaction) {
InvestmentTransactionDialog.show(account, clone, RegisterActions::addTransaction);
} else {
TransactionDialog.showAndWait(account, clone, RegisterActions::addTransaction);
}
} catch (final CloneNotSupportedException e) {
Logger.getLogger(RegisterActions.class.getName()).log(Level.SEVERE, e.getMessage(), e);
}
}
}
use of jgnash.engine.InvestmentTransaction 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.InvestmentTransaction in project jgnash by ccavanaugh.
the class SellSharePanel method modifyTransaction.
@Override
public void modifyTransaction(final Transaction tran) {
if (!(tran instanceof InvestmentTransaction)) {
throw new IllegalArgumentException("bad tranType");
}
clearForm();
datePanel.setDate(tran.getLocalDate());
List<TransactionEntry> entries = tran.getTransactionEntries();
feePanel.setTransactionEntries(((InvestmentTransaction) tran).getInvestmentFeeEntries());
gainsPanel.setTransactionEntries(((InvestmentTransaction) tran).getInvestmentGainLossEntries());
entries.stream().filter(e -> e instanceof TransactionEntrySellX).forEach(e -> {
final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityCombo.setSelectedNode(entry.getSecurityNode());
accountExchangePanel.setSelectedAccount(entry.getDebitAccount());
accountExchangePanel.setExchangedAmount(entry.getDebitAmount().abs());
});
updateTotalField();
modTrans = tran;
setReconciledState(tran.getReconciled(getAccount()));
}
Aggregations