Skip to content

Commit

Permalink
Set up CalculatedQuote format in SecuritiesChart
Browse files Browse the repository at this point in the history
* Use for purchase cost when several holding periods exists
* Use for the calculated purchase/sales price

Issue: #4327
  • Loading branch information
mierin12 authored and buchen committed Nov 9, 2024
1 parent 937eea7 commit 564454b
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,18 @@ else if (t instanceof PortfolioTransaction pt)
});
}

private void setupTooltipDisplayCalculatedQuote(String seriesLabel)
{
TimelineChartToolTip toolTip = chart.getToolTip();

int precision = FormatHelper.getCalculatedQuoteDisplayPrecision();
DecimalFormat calculatedFormat = new DecimalFormat(Values.CalculatedQuote.pattern());
calculatedFormat.setMinimumFractionDigits(precision);
calculatedFormat.setMaximumFractionDigits(precision);

toolTip.overrideValueFormat(seriesLabel, calculatedFormat);
}

private void addInvestmentTooltip(Composite composite, PortfolioTransaction t)
{
Label label = new Label(composite, SWT.NONE);
Expand All @@ -584,7 +596,7 @@ private void addInvestmentTooltip(Composite composite, PortfolioTransaction t)

label = new Label(composite, SWT.NONE);
label.setText(MessageFormat.format(Messages.LabelToolTipInvestmentDetails, Values.Share.format(t.getShares()),
Values.Quote.format(
Values.CalculatedQuote.format(
t.getGrossPricePerShare(converter.with(t.getSecurity().getCurrencyCode())))));
}

Expand Down Expand Up @@ -1771,6 +1783,8 @@ private void createFIFOPurchaseLineSeries(List<Double> values, List<LocalDate> d

configureSeriesPainter(series, dates.toArray(new LocalDate[0]), Doubles.toArray(values), colorFifoPurchasePrice,
2, LineStyle.SOLID, false, seriesCounter == 0);

setupTooltipDisplayCalculatedQuote(label);
}

private void addMovingAveragePurchasePrice(ChartInterval chartInterval)
Expand Down Expand Up @@ -1865,6 +1879,8 @@ private void createMovingAveragePurchaseLineSeries(List<Double> values, List<Loc

configureSeriesPainter(series, dates.toArray(new LocalDate[0]), Doubles.toArray(values),
colorMovingAveragePurchasePrice, 2, LineStyle.SOLID, false, seriesCounter == 0);

setupTooltipDisplayCalculatedQuote(label);
}

private Optional<Double> getLatestPurchasePrice()
Expand Down

0 comments on commit 564454b

Please sign in to comment.