use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class SecuritiesPerformanceView method createBottomTable.
@Override
protected // NOSONAR
void createBottomTable(// NOSONAR
Composite parent) {
Composite sash = new Composite(parent, SWT.NONE);
sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
// folder
CTabFolder folder = new CTabFolder(sash, SWT.BORDER);
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabChart);
Composite chartComposite = new Composite(folder, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(chartComposite);
item.setControl(chartComposite);
chart = new SecuritiesChart(chartComposite, getClient(), new CurrencyConverterImpl(factory, getClient().getBaseCurrency()));
latest = new SecurityDetailsViewer(sash, SWT.BORDER, getClient());
latest.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(latest.getControl())));
item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabTransactions);
Composite container = new Composite(folder, SWT.NONE);
item.setControl(container);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
folder.setSelection(0);
transactions = new TableViewer(container, SWT.FULL_SELECTION);
ShowHideColumnHelper support = new ShowHideColumnHelper(// $NON-NLS-1$
SecuritiesPerformanceView.class.getSimpleName() + "@bottom4", // $NON-NLS-1$
getPreferenceStore(), transactions, layout);
// date
Column column = new Column(Messages.ColumnDate, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Transaction t = (Transaction) e;
return Values.DateTime.format(t.getDateTime());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Transaction.class, "dateTime"), SWT.DOWN);
support.addColumn(column);
// transaction type
column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction)
return ((PortfolioTransaction) t).getType().toString();
else if (t instanceof AccountTransaction)
return ((AccountTransaction) t).getType().toString();
else if (t instanceof DividendTransaction)
return AccountTransaction.Type.DIVIDENDS.toString();
else
return Messages.LabelQuote;
}
});
support.addColumn(column);
// shares
column = new Column(Messages.ColumnShares, SWT.None, 80);
column.setLabelProvider(new // NOSONAR
SharesLabelProvider() {
@Override
public // NOSONAR
Long getValue(// NOSONAR
Object t) {
if (t instanceof PortfolioTransaction)
return ((PortfolioTransaction) t).getShares();
else if (t instanceof DividendInitialTransaction)
return ((DividendInitialTransaction) t).getPosition().getShares();
else if (t instanceof DividendFinalTransaction)
return ((DividendFinalTransaction) t).getPosition().getShares();
else if (t instanceof DividendTransaction)
return ((DividendTransaction) t).getShares() != 0L ? ((DividendTransaction) t).getShares() : null;
else
return null;
}
});
support.addColumn(column);
// dividend amount
column = new Column(Messages.ColumnDividendPayment, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnGrossDividend);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Money.format(((DividendTransaction) t).getGrossValue(), getClient().getBaseCurrency());
else
return null;
}
});
support.addColumn(column);
// dividend per share
column = new Column(Messages.ColumnDividendPerShare, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.AmountFraction.formatNonZero(((DividendTransaction) t).getDividendPerShare());
else
return null;
}
});
support.addColumn(column);
// dividend per share
column = new Column(Messages.ColumnPersonalDividendYield, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPersonalDividendYield_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYield());
else
return null;
}
});
support.addColumn(column);
// dividend per share (moving average)
column = new Column(Messages.ColumnPersonalDividendYieldMovingAverage, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPersonalDividendYieldMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYieldMovingAverage());
else
return null;
}
});
support.addColumn(column);
// einstandskurs / bewertung
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return null;
else
return Values.Money.format(((Transaction) t).getMonetaryAmount(), getClient().getBaseCurrency());
}
});
support.addColumn(column);
// purchase quote
column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction) {
PortfolioTransaction p = (PortfolioTransaction) t;
return Values.Quote.format(p.getGrossPricePerShare(), getClient().getBaseCurrency());
} else
return null;
}
});
support.addColumn(column);
// gegenkonto
column = new Column(Messages.ColumnAccount, SWT.None, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction) {
PortfolioTransaction p = (PortfolioTransaction) t;
return p.getCrossEntry() != null ? p.getCrossEntry().getCrossOwner(p).toString() : null;
} else if (t instanceof DividendTransaction) {
return ((DividendTransaction) t).getAccount().getName();
} else {
return null;
}
}
});
support.addColumn(column);
// note
// $NON-NLS-1$
column = new Column("note", Messages.ColumnNote, SWT.LEFT, 22);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return ((Transaction) r).getNote();
}
@Override
public Image getImage(Object r) {
String note = ((Transaction) r).getNote();
return note != null && note.length() > 0 ? Images.NOTE.image() : null;
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Transaction.class, "note"));
support.addColumn(column);
support.createColumns();
transactions.getTable().setHeaderVisible(true);
transactions.getTable().setLinesVisible(true);
transactions.setContentProvider(ArrayContentProvider.getInstance());
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class PerformanceView method createTransactionViewer.
private TableViewer createTransactionViewer(CTabFolder folder, String title) {
Composite container = new Composite(folder, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
TableViewer transactionViewer = new TableViewer(container, SWT.FULL_SELECTION);
transactionViewer.addSelectionChangedListener(event -> {
TransactionPair<?> tx = ((TransactionPair<?>) ((IStructuredSelection) event.getSelection()).getFirstElement());
if (tx != null && tx.getTransaction().getSecurity() != null)
selectionService.setSelection(new SecuritySelection(getClient(), tx.getTransaction().getSecurity()));
});
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
PerformanceView.class.getSimpleName() + "@2" + title, getPreferenceStore(), transactionViewer, layout);
Column column = new Column(Messages.ColumnDate, SWT.None, 100);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.DateTime.format(((TransactionPair<?>) element).getTransaction().getDateTime());
}
});
column.setSorter(ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getDateTime()), SWT.UP);
support.addColumn(column);
column = new Column(Messages.ColumnTransactionType, SWT.LEFT, 100);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Transaction t = ((TransactionPair<?>) element).getTransaction();
return t instanceof AccountTransaction ? ((AccountTransaction) t).getType().toString() : ((PortfolioTransaction) t).getType().toString();
}
});
column.setSorter(ColumnViewerSorter.create(e -> {
Transaction t = ((TransactionPair<?>) e).getTransaction();
return t instanceof AccountTransaction ? ((AccountTransaction) t).getType().toString() : ((PortfolioTransaction) t).getType().toString();
}));
support.addColumn(column);
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.Money.format(((TransactionPair<?>) element).getTransaction().getMonetaryAmount(), getClient().getBaseCurrency());
}
});
column.setSorter(ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getMonetaryAmount()));
support.addColumn(column);
addTaxesColumn(support);
addFeesColumn(support);
addSecurityColumn(support);
addPortfolioColumn(support);
addAccountColumn(support);
column = new NoteColumn();
column.setEditingSupport(null);
support.addColumn(column);
support.createColumns();
transactionViewer.getTable().setHeaderVisible(true);
transactionViewer.getTable().setLinesVisible(true);
transactionViewer.setContentProvider(ArrayContentProvider.getInstance());
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(title);
item.setControl(container);
return transactionViewer;
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class AccountListView method fillTransactionsContextMenu.
private // NOSONAR
void fillTransactionsContextMenu(// NOSONAR
IMenuManager manager) {
Account account = (Account) transactions.getData(Account.class.toString());
if (account == null)
return;
AccountTransaction transaction = (AccountTransaction) ((IStructuredSelection) transactions.getSelection()).getFirstElement();
if (transaction != null) {
Action action = createEditAction(account, transaction);
action.setAccelerator(SWT.MOD1 | 'E');
manager.add(action);
manager.add(new Separator());
}
accountMenu.menuAboutToShow(manager, account, transaction != null ? transaction.getSecurity() : null);
if (transaction != null) {
manager.add(new Separator());
manager.add(new Action(Messages.AccountMenuDeleteTransaction) {
@Override
public void run() {
Object[] selection = ((IStructuredSelection) transactions.getSelection()).toArray();
Account account = (Account) transactions.getData(Account.class.toString());
if (selection == null || selection.length == 0 || account == null)
return;
for (Object transaction : selection) account.deleteTransaction((AccountTransaction) transaction, getClient());
markDirty();
transaction2balance.clear();
updateBalance(account);
accounts.refresh();
transactions.setInput(account.getTransactions());
}
});
}
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class ComdirectPDFExtractor method addTaxRefunds.
@SuppressWarnings("nls")
private void addTaxRefunds(DocumentType type, String blockMarker) {
// tax refunds --> separate transaction
Block block = new Block(blockMarker);
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction t = new AccountTransaction();
t.setType(AccountTransaction.Type.TAX_REFUND);
return t;
}).section(//
"date").match(//
"Geschäftstag *: (?<date>\\d+.\\d+.\\d{4}+) .*").assign((t, v) -> t.setDateTime(asDate(v.get("date")))).section("isin", "name", //
"wkn").find(//
"Wertpapier-Bezeichnung *WPKNR/ISIN *").match(//
"^(?<name>(\\S{1,} )*) *(?<wkn>\\S*) *$").match(//
"(\\S{1,} )* *(?<isin>\\S*) *$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("tax").optional().match(//
"^e *r *s *t *a *t *t *e *t *e *S *t *e *u *e *r *n *(?<tax>.*)$").assign((t, v) -> {
Unit unit = createTaxUnit(v.get("tax"));
if (unit == null || unit.getAmount().isZero())
return;
t.setMonetaryAmount(unit.getAmount());
}).wrap(t -> t.getAmount() == 0L ? null : new TransactionItem(t)));
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class CommerzbankPDFExtractor method addDividendTransaction.
private void addDividendTransaction() {
DocumentType type = new DocumentType("E r t r a g s g u t s c h r i f t");
this.addDocumentTyp(type);
Block block = new Block("E r t r a g s g u t s c h r i f t");
type.addBlock(block);
block.set(new Transaction<AccountTransaction>().subject(() -> {
AccountTransaction transaction = new AccountTransaction();
transaction.setType(AccountTransaction.Type.DIVIDENDS);
return transaction;
}).section("date", "amount", //
"currency").match(".*Zu I h r e n Gunsten.*").match("^.* (?<date>\\d \\d . \\d \\d . \\d \\d \\d \\d) (?<currency>\\w{3}+)(?<amount>( \\d)*( \\.)?( \\d)* ,( \\d)*)$").assign((t, v) -> {
t.setDateTime(asDate(stripBlanks(v.get("date"))));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(stripBlanks(v.get("amount"))));
}).section("wkn", "name", "shares", "isin").match(".*W e r t p a p i e r - B e z e i c h n u n g.*").match("p e r \\d \\d . \\d \\d . \\d \\d \\d \\d (?<name>.*) (?<wkn>\\S*)").match("^STK (?<shares>(\\d )*(\\. )?(\\d )*, (\\d )*).* (?<isin>\\S*)$").assign((t, v) -> {
// if necessary, create the security with the
// currency of the transaction
v.put("currency", t.getCurrencyCode());
t.setSecurity(getOrCreateSecurity(v));
t.setShares(asShares(stripBlanks(v.get("shares"))));
}).wrap(TransactionItem::new));
}
Aggregations