use of name.abuchen.portfolio.model.CrossEntry in project portfolio by buchen.
the class PerformanceView method addAccountColumn.
private void addAccountColumn(ShowHideColumnHelper support) {
Column column = new Column(Messages.ColumnAccount, SWT.LEFT, 100);
Function<Object, Account> getAccount = element -> {
TransactionPair<?> pair = (TransactionPair<?>) element;
if (pair.getOwner() instanceof Account)
return (Account) pair.getOwner();
CrossEntry crossEntry = pair.getTransaction().getCrossEntry();
if (crossEntry == null)
return null;
TransactionOwner<?> other = crossEntry.getCrossOwner(pair.getTransaction());
return other instanceof Account ? ((Account) other) : null;
};
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Account account = getAccount.apply(element);
return account != null ? account.getName() : null;
}
@Override
public Image getImage(Object element) {
Account account = getAccount.apply(element);
return account != null ? Images.ACCOUNT.image() : null;
}
});
column.setSorter(ColumnViewerSorter.create(e -> {
Account account = getAccount.apply(e);
return account != null ? account.getName() : null;
}));
support.addColumn(column);
}
use of name.abuchen.portfolio.model.CrossEntry in project portfolio by buchen.
the class DanglingAccountsCheck method execute.
@Override
public List<Issue> execute(Client client) {
Set<Account> accounts = new HashSet<Account>(client.getAccounts());
for (Portfolio portfolio : client.getPortfolios()) {
Account referenceAccount = portfolio.getReferenceAccount();
check(client, accounts, referenceAccount);
for (PortfolioTransaction transaction : portfolio.getTransactions()) {
CrossEntry entry = transaction.getCrossEntry();
if (!(entry instanceof BuySellEntry))
continue;
Account account = (Account) entry.getCrossOwner(transaction);
check(client, accounts, account);
}
}
return Collections.emptyList();
}
Aggregations