Skip to content

Commit

Permalink
Add derived data series to statements of assets chart
Browse files Browse the repository at this point in the history
Uses DerivedDataSeries to hold a reference to the underlying data
series (base) and the aspect to be shown (ClientDataSeries).

Issue: #3754
Issue: #4235
Issue: #4396
Co-authored-by: Shivam Paw <[email protected]>
Co-authored-by: mierin12 <[email protected]>
Co-authored-by: Andreas Buchen <[email protected]>
  • Loading branch information
3 people committed Dec 20, 2024
1 parent a1e6f78 commit 9a59081
Show file tree
Hide file tree
Showing 26 changed files with 279 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class Messages extends NLS
public static String ChartSeriesBenchmarkSuffix;
public static String ChartSeriesCopySeriesFromOtherChart;
public static String ChartSeriesPickerAddBenchmark;
public static String ChartSeriesPickerAddDerivedData;
public static String ChartSeriesPickerAddItem;
public static String ChartSeriesPickerColor;
public static String ChartSeriesPickerDialogMsg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,5 @@ cthiel
myrdd
mosswald82
verglor
liuhaoXD
liuhaoXD
shivampaw
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ ChartSeriesCopySeriesFromOtherChart = Copy from

ChartSeriesPickerAddBenchmark = Add benchmark...

ChartSeriesPickerAddDerivedData = Add derived data series ...

ChartSeriesPickerAddItem = Add data series...

ChartSeriesPickerColor = Color...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ ChartSeriesCopySeriesFromOtherChart = Kop\u00EDrovat z

ChartSeriesPickerAddBenchmark = P\u0159idat benchmark...

ChartSeriesPickerAddDerivedData = P\u0159id\u00E1n\u00ED odvozen\u00FDch datov\u00FDch \u0159ad ...

ChartSeriesPickerAddItem = P\u0159idat datovou \u0159adu...

ChartSeriesPickerColor = Barva...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = Kopier fra

ChartSeriesPickerAddBenchmark = Tilf\u00F8j ydeevne...

ChartSeriesPickerAddDerivedData = Tilf\u00F8j afledte dataserier ...

ChartSeriesPickerAddItem = Tilf\u00F8j dataserier...

ChartSeriesPickerColor = Farve...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = \u00DCbernehmen aus

ChartSeriesPickerAddBenchmark = Benchmark hinzuf\u00FCgen...

ChartSeriesPickerAddDerivedData = Abgeleitete Datenreihen hinzuf\u00FCgen ...

ChartSeriesPickerAddItem = Datenreihe hinzuf\u00FCgen...

ChartSeriesPickerColor = Farbe...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = Incorporar las series de

ChartSeriesPickerAddBenchmark = A\u00F1adir series de referencia...

ChartSeriesPickerAddDerivedData = A\u00F1adir series de datos derivados ...

ChartSeriesPickerAddItem = A\u00F1adir series de datos...

ChartSeriesPickerColor = Color...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ ChartSeriesCopySeriesFromOtherChart = Copier de

ChartSeriesPickerAddBenchmark = Ajouter une r\u00E9f\u00E9rence/benchmark...

ChartSeriesPickerAddDerivedData = Ajouter des s\u00E9ries de donn\u00E9es d\u00E9riv\u00E9es ...

ChartSeriesPickerAddItem = Ajouter des s\u00E9ries de donn\u00E9es...

ChartSeriesPickerColor = Couleur...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = Copia da
ChartSeriesPickerAddBenchmark = Aggiungi un benchmark
ChartSeriesPickerAddDerivedData = Aggiungere serie di dati derivati ...
ChartSeriesPickerAddItem = Aggiungi serie dati...
ChartSeriesPickerColor = Colore...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = Kopi\u00EBren van
ChartSeriesPickerAddBenchmark = Benchmark toevoegen...
ChartSeriesPickerAddDerivedData = Afgeleide gegevensreeksen toevoegen ...
ChartSeriesPickerAddItem = Gegevensreeks toevoegen...
ChartSeriesPickerColor = Kleur...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = Kopiuj z

ChartSeriesPickerAddBenchmark = Dodaj benchmark\u2026

ChartSeriesPickerAddDerivedData = Dodaj pochodne serie danych ...

ChartSeriesPickerAddItem = Dodaj serie danych ...

ChartSeriesPickerColor = Kolor...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = Copiar de

ChartSeriesPickerAddBenchmark = Adicionar refer\u00EAncia...

ChartSeriesPickerAddDerivedData = Adicionar s\u00E9ries de dados derivados ...

ChartSeriesPickerAddItem = Adicionar s\u00E9rie de dados...

ChartSeriesPickerColor = Cor...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = Copiar de

ChartSeriesPickerAddBenchmark = Adicionar Benchmark...

ChartSeriesPickerAddDerivedData = Adicionar s\u00E9ries de dados derivados ...

ChartSeriesPickerAddItem = Adicionar s\u00E9rie de dados...

ChartSeriesPickerColor = Cor...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = \u041A\u043E\u043F\u0438\u0440\u043E\u0432

ChartSeriesPickerAddBenchmark = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0431\u0435\u043D\u0447\u043C\u0430\u0440\u043A...

ChartSeriesPickerAddDerivedData = \u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u043D\u044B\u0435 \u0441\u0435\u0440\u0438\u0438 \u0434\u0430\u043D\u043D\u044B\u0445 ...

ChartSeriesPickerAddItem = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0435\u0440\u0438\u044E \u0434\u0430\u043D\u043D\u044B\u0445...

ChartSeriesPickerColor = \u0426\u0432\u0435\u0442...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = Kop\u00EDrova\u0165 z
ChartSeriesPickerAddBenchmark = Prida\u0165 Benchmark...
ChartSeriesPickerAddDerivedData = Pridanie odvoden\u00FDch radov \u00FAdajov ...
ChartSeriesPickerAddItem = Prida\u0165 d\u00E1tov\u00FA radu...
ChartSeriesPickerColor = Farba...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = \u590D\u5236\u81EA

ChartSeriesPickerAddBenchmark = \u6DFB\u52A0\u57FA\u51C6...

ChartSeriesPickerAddDerivedData = \u6DFB\u52A0\u6D3E\u751F\u6570\u636E\u7CFB\u5217 ...

ChartSeriesPickerAddItem = \u6DFB\u52A0\u6570\u636E\u7CFB\u5217...

ChartSeriesPickerColor = \u989C\u8272...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ChartSeriesCopySeriesFromOtherChart = \u8907\u88FD\u81EA

ChartSeriesPickerAddBenchmark = \u65B0\u589E\u6307\u6A19...

ChartSeriesPickerAddDerivedData = \u65B0\u589E\u884D\u751F\u8CC7\u6599\u7CFB\u5217 ...

ChartSeriesPickerAddItem = \u65B0\u589E\u6578\u5217...

ChartSeriesPickerColor = \u984F\u8272...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public void configMenuAboutToShow(IMenuManager manager)

if (dataSeriesSet.getUseCase() != DataSeries.UseCase.STATEMENT_OF_ASSETS)
manager.add(new SimpleAction(Messages.ChartSeriesPickerAddBenchmark, a -> doAddSeries(true)));
else
manager.add(new SimpleAction(Messages.ChartSeriesPickerAddDerivedData, a -> doAddDerivedSeries()));

addCopyFromOtherChartsMenu(manager);
}
Expand Down Expand Up @@ -136,6 +138,33 @@ private void doAddSeries(boolean showOnlyBenchmark)
fireUpdate();
}

private void doAddDerivedSeries()
{
List<DataSeries> list = new ArrayList<>(dataSeriesSet.getAvailableDerivedSeries());

// remove already selected items
for (DataSeries s : selectedSeries)
list.remove(s);

DataSeriesSelectionDialog dialog = new DataSeriesSelectionDialog(Display.getDefault().getActiveShell(), client);
dialog.setElementsDerivedData(list);
dialog.setExpandTree(false);

if (dialog.open() != DataSeriesSelectionDialog.OK)
return;

List<DataSeries> result = dialog.getResult();
if (result.isEmpty())
return;

result.forEach(series -> {
series.setVisible(true);
selectedSeries.add(series);
});

fireUpdate();
}

private void addCopyFromOtherChartsMenu(IMenuManager manager)
{
String[] charts = new String[] { //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,45 @@ public enum UseCase
*/
public enum ClientDataSeries
{
TOTALS, INVESTED_CAPITAL, ABSOLUTE_INVESTED_CAPITAL, TRANSFERALS, TRANSFERALS_ACCUMULATED, TAXES, TAXES_ACCUMULATED, ABSOLUTE_DELTA, ABSOLUTE_DELTA_ALL_RECORDS, //
DIVIDENDS, DIVIDENDS_ACCUMULATED, INTEREST, INTEREST_ACCUMULATED, DELTA_PERCENTAGE, INTEREST_CHARGE, INTEREST_CHARGE_ACCUMULATED, //
EARNINGS, EARNINGS_ACCUMULATED, FEES, FEES_ACCUMULATED;
TOTALS(Messages.LabelTotalSum), //
TRANSFERALS(Messages.LabelTransferals), //
TRANSFERALS_ACCUMULATED(Messages.LabelAccumulatedTransferals), //
INVESTED_CAPITAL(Messages.LabelInvestedCapital), //
ABSOLUTE_INVESTED_CAPITAL(Messages.LabelAbsoluteInvestedCapital), //
ABSOLUTE_DELTA(Messages.LabelDelta), //
ABSOLUTE_DELTA_ALL_RECORDS(Messages.LabelAbsoluteDelta), //
DIVIDENDS(Messages.LabelDividends), //
DIVIDENDS_ACCUMULATED(Messages.LabelAccumulatedDividends), //
INTEREST(Messages.LabelInterest), //
INTEREST_ACCUMULATED(Messages.LabelAccumulatedInterest), //
INTEREST_CHARGE(Messages.LabelInterestCharge), //
INTEREST_CHARGE_ACCUMULATED(Messages.LabelAccumulatedInterestCharge), //
EARNINGS(Messages.LabelEarnings), //
EARNINGS_ACCUMULATED(Messages.LabelAccumulatedEarnings), //
FEES(Messages.LabelFees), //
FEES_ACCUMULATED(Messages.LabelFeesAccumulated), //
TAXES(Messages.ColumnTaxes), //
TAXES_ACCUMULATED(Messages.LabelAccumulatedTaxes), //

DELTA_PERCENTAGE(Messages.LabelAggregationDaily);

private String label;

private ClientDataSeries(String label)
{
this.label = label;
}

public String getLabel()
{
return label;
}

@Override
public String toString()
{
return label;
}
}

/**
Expand All @@ -52,6 +88,7 @@ public enum Type
ACCOUNT("Account", i -> ((Account) i).getUUID()), //$NON-NLS-1$
ACCOUNT_PRETAX("Account-PreTax", i -> ((Account) i).getUUID()), //$NON-NLS-1$
PORTFOLIO("Portfolio", i -> ((Portfolio) i).getUUID()), //$NON-NLS-1$
DERIVED_DATA_SERIES("Derived-", i -> ((DerivedDataSeries) i).getUUID()), //$NON-NLS-1$
PORTFOLIO_PRETAX("Portfolio-PreTax", i -> ((Portfolio) i).getUUID()), //$NON-NLS-1$
PORTFOLIO_PLUS_ACCOUNT("[+]Portfolio", i -> ((Portfolio) i).getUUID()), //$NON-NLS-1$
PORTFOLIO_PLUS_ACCOUNT_PRETAX("[+]Portfolio-PreTax", i -> ((Portfolio) i).getUUID()), //$NON-NLS-1$
Expand Down Expand Up @@ -146,6 +183,15 @@ public String getSearchLabel()
buf.append(" (").append(parent.getPathName(false)).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
}

if (instance instanceof DerivedDataSeries derived
&& derived.getBaseDataSeries().getInstance() instanceof Classification classification)
{
Classification parent = classification.getParent();

if (parent.getParent() != null)
buf.append(" (").append(parent.getPathName(false)).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
}

if (isBenchmark())
buf.append(" ").append(Messages.ChartSeriesBenchmarkSuffix); //$NON-NLS-1$

Expand Down Expand Up @@ -214,23 +260,17 @@ public void setLineWidth(int lineWidth)

public Image getImage()
{
switch (type)
switch (instance instanceof DerivedDataSeries derived ? derived.getBaseDataSeries().getType() : type)
{
case SECURITY:
case SECURITY_BENCHMARK:
case SECURITY, SECURITY_BENCHMARK:
return Images.SECURITY.image();
case ACCOUNT:
case ACCOUNT_PRETAX:
case ACCOUNT, ACCOUNT_PRETAX:
return Images.ACCOUNT.image();
case PORTFOLIO:
case PORTFOLIO_PRETAX:
case PORTFOLIO_PLUS_ACCOUNT:
case PORTFOLIO_PLUS_ACCOUNT_PRETAX:
case PORTFOLIO, PORTFOLIO_PRETAX, PORTFOLIO_PLUS_ACCOUNT, PORTFOLIO_PLUS_ACCOUNT_PRETAX:
return Images.PORTFOLIO.image();
case CLASSIFICATION:
return Images.CATEGORY.image();
case CLIENT_FILTER:
case CLIENT_FILTER_PRETAX:
case CLIENT_FILTER, CLIENT_FILTER_PRETAX:
return Images.FILTER_OFF.image();
default:
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ private PerformanceIndex calculate(DataSeries series, Interval reportingPeriod)
new WithoutTaxesFilter().filter(pretax.getFilter().filter(client)), converter,
reportingPeriod, warnings);

case DERIVED_DATA_SERIES:
// redirect to the #lookup method to use the cached data, if
// available
var derivedDataSeries = (DerivedDataSeries) series.getInstance();
return lookup(derivedDataSeries.getBaseDataSeries(), reportingPeriod);

default:
throw new IllegalArgumentException(series.getType().name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ private PaintItem(Composite parent, DataSeries series)
setToolTipText(TextUtil.wordwrap(security.toInfoString()));
else if (series.getInstance() instanceof Classification classification)
setToolTipText(classification.getPathName(true));
else if (series.getInstance() instanceof DerivedDataSeries derived
&& derived.getBaseDataSeries().getInstance() instanceof Classification classification)
setToolTipText(derived.getAspect().getLabel() + ": " + classification.getPathName(true)); //$NON-NLS-1$
else
setToolTipText(series.getLabel());
}
Expand Down
Loading

0 comments on commit 9a59081

Please sign in to comment.