Skip to content

Commit

Permalink
PortfolioListView: Add column with balance of reference account
Browse files Browse the repository at this point in the history
Thus, portfolio list view will now have complete information: securities
account and its MTM balance, and reference account with its cash balance.
  • Loading branch information
pfalcon committed Dec 7, 2024
1 parent 4b3e78d commit 4980299
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.text.MessageFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

import jakarta.annotation.PostConstruct;
Expand Down Expand Up @@ -256,6 +258,23 @@ public String getText(Object element)
}));
portfolioColumns.addColumn(column);

column = new Column("ref_cash_bal", "Balance of reference account", SWT.RIGHT, 100); //$NON-NLS-1$
column.setLabelProvider(new ColumnLabelProvider()
{
CurrencyConverter converter = new CurrencyConverterImpl(factory, getClient().getBaseCurrency());

@Override
public String getText(Object element)
{
Portfolio p = (Portfolio) element;
var refAcc = p.getReferenceAccount();
return Values.Amount.format((refAcc.getCurrentAmount(LocalDateTime.now().with(LocalTime.MAX))));
}
});
ColumnViewerSorter.create(o -> ((Portfolio) o).getReferenceAccount().getCurrentAmount(LocalDateTime.now().with(LocalTime.MAX)))
.attachTo(column);
portfolioColumns.addColumn(column);

column = new NoteColumn();
column.getEditingSupport().addListener(this);
portfolioColumns.addColumn(column);
Expand Down

0 comments on commit 4980299

Please sign in to comment.