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
  • Loading branch information
mierin12 committed Sep 16, 2024
1 parent 8f0b941 commit 27c7b9a
Show file tree
Hide file tree
Showing 25 changed files with 389 additions and 167 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 @@ -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
@@ -1,9 +1,6 @@
package name.abuchen.portfolio.ui.views.dataseries;

import java.util.Arrays;
import java.util.EnumMap;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;

import org.eclipse.swt.graphics.Image;
Expand Down Expand Up @@ -43,31 +40,72 @@ public enum ClientDataSeries
EARNINGS, EARNINGS_ACCUMULATED, FEES, FEES_ACCUMULATED;
}

public static final Map<ClientDataSeries, String> statementOfAssetsDataSeriesLabels = new EnumMap<>(ClientDataSeries.class)
/**
* Data series available for the Type_Parent type.
*/
public enum ClientDataSeriesType
{
private static final long serialVersionUID = 1319016001158914537L;
TRANSFERALS(ClientDataSeries.TRANSFERALS, Messages.LabelTransferals, false), //
TRANSFERALS_ACCUMULATED(ClientDataSeries.TRANSFERALS_ACCUMULATED, Messages.LabelAccumulatedTransferals, true,
true), //
INVESTED_CAPITAL(ClientDataSeries.INVESTED_CAPITAL, Messages.LabelInvestedCapital, true, true), //
ABSOLUTE_INVESTED_CAPITAL(ClientDataSeries.ABSOLUTE_INVESTED_CAPITAL, Messages.LabelAbsoluteInvestedCapital,
true, true), //
ABSOLUTE_DELTA(ClientDataSeries.ABSOLUTE_DELTA, Messages.LabelDelta, true), //
ABSOLUTE_DELTA_ALL_RECORDS(ClientDataSeries.ABSOLUTE_DELTA_ALL_RECORDS, Messages.LabelAbsoluteDelta, true), //
DIVIDENDS(ClientDataSeries.DIVIDENDS, Messages.LabelDividends, false), //
DIVIDENDS_ACCUMULATED(ClientDataSeries.DIVIDENDS_ACCUMULATED, Messages.LabelAccumulatedDividends, true), //
INTEREST(ClientDataSeries.INTEREST, Messages.LabelInterest, false), //
INTEREST_ACCUMULATED(ClientDataSeries.INTEREST_ACCUMULATED, Messages.LabelAccumulatedInterest, true), //
INTEREST_CHARGE(ClientDataSeries.INTEREST_CHARGE, Messages.LabelInterestCharge, false), //
INTEREST_CHARGE_ACCUMULATED(ClientDataSeries.INTEREST_CHARGE_ACCUMULATED,
Messages.LabelAccumulatedInterestCharge, true), //
EARNINGS(ClientDataSeries.EARNINGS, Messages.LabelEarnings, false), //
EARNINGS_ACCUMULATED(ClientDataSeries.EARNINGS_ACCUMULATED, Messages.LabelAccumulatedEarnings, true), //
FEES(ClientDataSeries.FEES, Messages.LabelFees, false), //
FEES_ACCUMULATED(ClientDataSeries.FEES_ACCUMULATED, Messages.LabelFeesAccumulated, true), //
TAXES(ClientDataSeries.TAXES, Messages.ColumnTaxes, false), //
TAXES_ACCUMULATED(ClientDataSeries.TAXES_ACCUMULATED, Messages.LabelAccumulatedTaxes, true); //

private String label;
private boolean isLine;
private boolean isArea;
private ClientDataSeries clientDataSeries;

private ClientDataSeriesType(ClientDataSeries clientDataSeries, String label, boolean isLine)
{
this(clientDataSeries, label, isLine, false);
}

private ClientDataSeriesType(ClientDataSeries clientDataSeries, String label, boolean isLine, boolean isArea)
{
put(ClientDataSeries.TOTALS, Messages.LabelTotalSum);
put(ClientDataSeries.TRANSFERALS, Messages.LabelTransferals);
put(ClientDataSeries.INVESTED_CAPITAL, Messages.LabelInvestedCapital);
put(ClientDataSeries.ABSOLUTE_INVESTED_CAPITAL, Messages.LabelAbsoluteInvestedCapital);
put(ClientDataSeries.ABSOLUTE_DELTA, Messages.LabelDelta);
put(ClientDataSeries.ABSOLUTE_DELTA_ALL_RECORDS, Messages.LabelAbsoluteDelta);
put(ClientDataSeries.TAXES, Messages.ColumnTaxes);
put(ClientDataSeries.TAXES_ACCUMULATED, Messages.LabelAccumulatedTaxes);
put(ClientDataSeries.DIVIDENDS, Messages.LabelDividends);
put(ClientDataSeries.DIVIDENDS_ACCUMULATED, Messages.LabelAccumulatedDividends);
put(ClientDataSeries.INTEREST, Messages.LabelInterest);
put(ClientDataSeries.INTEREST_ACCUMULATED, Messages.LabelAccumulatedInterest);
put(ClientDataSeries.INTEREST_CHARGE, Messages.LabelInterestCharge);
put(ClientDataSeries.INTEREST_CHARGE_ACCUMULATED, Messages.LabelAccumulatedInterestCharge);
put(ClientDataSeries.EARNINGS, Messages.LabelEarnings);
put(ClientDataSeries.EARNINGS_ACCUMULATED, Messages.LabelAccumulatedEarnings);
put(ClientDataSeries.FEES, Messages.LabelFees);
put(ClientDataSeries.FEES_ACCUMULATED, Messages.LabelFeesAccumulated);
this.label = label;
this.isLine = isLine;
this.isArea = isArea;
this.clientDataSeries = clientDataSeries;
}
};

public boolean isLineSerie()
{
return isLine;
}

public boolean isAreaSerie()
{
return isArea;
}

public ClientDataSeries getClientDataSeries()
{
return clientDataSeries;
}

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

/**
* Type of objects for which the PerformanceIndex is calculated.
Expand Down Expand Up @@ -105,7 +143,7 @@ String buildUUID(Object instance)
}

private Type type;
private Object[] groups;
private Object group;
private Object instance;
private String label;
private boolean isLineChart = true;
Expand All @@ -128,19 +166,10 @@ String buildUUID(Object instance)
this(type, null, instance, label, color);
}

/* package */ DataSeries(Type type, Object[] groups, Object instance, String label, RGB color)
{
this.type = type;
this.groups = groups;
this.instance = instance;
this.label = label;
this.color = color;
}

/* package */ DataSeries(Type type, Object group, Object instance, String label, RGB color)
{
this.type = type;
this.groups = group != null ? Arrays.asList(group).toArray() : null;
this.group = group;
this.instance = instance;
this.label = label;
this.color = color;
Expand All @@ -151,9 +180,9 @@ public Type getType()
return type;
}

public Object[] getGroups()
public Object getGroup()
{
return groups;
return group;
}

public Object getInstance()
Expand All @@ -163,8 +192,12 @@ public Object getInstance()

public String getLabel()
{
if (instance instanceof GroupedDataSeries c && groups.length > 0)
return groups[groups.length - 1] + " - " + label; //$NON-NLS-1$
if (instance instanceof GroupedDataSeries groupedDataSeries)
return groupedDataSeries.getClientDataSeriesLabel() + " (" //$NON-NLS-1$
+ (groupedDataSeries.getParentObject() instanceof Classification classification
? classification.getName()
: label)
+ ")"; //$NON-NLS-1$

return isBenchmark() ? label + " " + Messages.ChartSeriesBenchmarkSuffix : label; //$NON-NLS-1$
}
Expand Down Expand Up @@ -256,7 +289,8 @@ public void setLineWidth(int lineWidth)

public Image getImage()
{
switch (type)
switch (instance instanceof GroupedDataSeries groupedDataSeries ? groupedDataSeries.getParentObjectType()
: type)
{
case SECURITY:
case SECURITY_BENCHMARK:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ private PerformanceIndex calculate(DataSeries series, Interval reportingPeriod)
return PerformanceIndex.forPortfolio(client, converter, (Portfolio) series.getInstance(),
reportingPeriod, warnings);

case TYPE_PARENT:
var instance = ((GroupedDataSeries) series.getInstance());

return instance.getPerformanceIndexMethod(client, converter, reportingPeriod, warnings);

case PORTFOLIO_PRETAX:
return calculatePortfolioPretax(series, reportingPeriod, warnings);

Expand Down Expand Up @@ -140,6 +135,10 @@ private PerformanceIndex calculate(DataSeries series, Interval reportingPeriod)
new WithoutTaxesFilter().filter(pretax.getFilter().filter(client)), converter,
reportingPeriod, warnings);

case TYPE_PARENT:
var instance = ((GroupedDataSeries) series.getInstance());
return instance.getPerformanceIndexMethod(client, converter, reportingPeriod, warnings);

default:
throw new IllegalArgumentException(series.getType().name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ 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 GroupedDataSeries groupedDataSeries
&& ((GroupedDataSeries) series.getInstance())
.getParentObject() instanceof Classification classification)
setToolTipText(groupedDataSeries.getClientDataSeriesLabel() + " (" + classification.getPathName(true) //$NON-NLS-1$
+ ")"); //$NON-NLS-1$
else
setToolTipText(series.getLabel());
}
Expand Down
Loading

0 comments on commit 27c7b9a

Please sign in to comment.