use of name.abuchen.portfolio.money.ExchangeRate in project portfolio by buchen.
the class ExchangeRateWidget method update.
@Override
void update() {
this.title.setText(getWidget().getLabel());
ReportingPeriod period = get(ReportingPeriodConfig.class).getReportingPeriod();
ExchangeRateTimeSeries series = get(ExchangeRateSeriesConfig.class).getSeries();
Optional<ExchangeRate> rate = series.lookupRate(period.getEndDate());
this.indicator.setText(series.getLabel() + ' ' + (rate.isPresent() ? Values.ExchangeRate.format(rate.get().getValue()) : '-'));
}
use of name.abuchen.portfolio.money.ExchangeRate in project portfolio by buchen.
the class ChainedExchangeRateTimeSeriesTest method testIfSomeRatesDoNotExist.
@Test
public void testIfSomeRatesDoNotExist() {
ExchangeRateTimeSeriesImpl first = new ExchangeRateTimeSeriesImpl();
first.addRate(new ExchangeRate(LocalDate.parse("2014-11-30"), BigDecimal.valueOf(1)));
ExchangeRateTimeSeriesImpl second = new ExchangeRateTimeSeriesImpl();
ChainedExchangeRateTimeSeries chained = new ChainedExchangeRateTimeSeries(first, second);
assertThat(chained.lookupRate(LocalDate.parse("2014-11-30")).isPresent(), is(false));
}
use of name.abuchen.portfolio.money.ExchangeRate in project portfolio by buchen.
the class ExchangeRateTimeSeriesImplTest method testAddingOfExchangeRates.
@Test
public void testAddingOfExchangeRates() {
ExchangeRateTimeSeriesImpl series = new ExchangeRateTimeSeriesImpl(null, "EUR", "USD");
series.addRate(new ExchangeRate(LocalDate.parse("2014-12-01"), BigDecimal.valueOf(1)));
series.addRate(new ExchangeRate(LocalDate.parse("2014-12-01"), BigDecimal.valueOf(2)));
assertProperties(series);
}
use of name.abuchen.portfolio.money.ExchangeRate in project portfolio by buchen.
the class ExchangeRateTimeSeriesImplTest method testCreationFromTemplate.
@Test
public void testCreationFromTemplate() {
ExchangeRateTimeSeriesImpl template = new ExchangeRateTimeSeriesImpl(null, "EUR", "USD");
template.addRate(new ExchangeRate(LocalDate.parse("2014-12-01"), BigDecimal.valueOf(1)));
template.addRate(new ExchangeRate(LocalDate.parse("2014-12-01"), BigDecimal.valueOf(2)));
ExchangeRateTimeSeriesImpl series = new ExchangeRateTimeSeriesImpl(template);
assertProperties(series);
}
use of name.abuchen.portfolio.money.ExchangeRate in project portfolio by buchen.
the class ExchangeRateTimeSeriesImplTest method testLookupOfExchangeRate.
@Test
public void testLookupOfExchangeRate() {
ExchangeRateTimeSeriesImpl series = new ExchangeRateTimeSeriesImpl();
series.addRate(new ExchangeRate(LocalDate.parse("2014-12-01"), BigDecimal.valueOf(1)));
series.addRate(new ExchangeRate(LocalDate.parse("2014-12-02"), BigDecimal.valueOf(2)));
series.addRate(new ExchangeRate(LocalDate.parse("2014-12-03"), BigDecimal.valueOf(3)));
assertThat(series.lookupRate(LocalDate.parse("2014-11-30")).get().getValue(), is(BigDecimal.valueOf(1)));
assertThat(series.lookupRate(LocalDate.parse("2014-12-01")).get().getValue(), is(BigDecimal.valueOf(1)));
assertThat(series.lookupRate(LocalDate.parse("2014-12-02")).get().getValue(), is(BigDecimal.valueOf(2)));
assertThat(series.lookupRate(LocalDate.parse("2014-12-03")).get().getValue(), is(BigDecimal.valueOf(3)));
assertThat(series.lookupRate(LocalDate.parse("2014-12-04")).get().getValue(), is(BigDecimal.valueOf(3)));
}
Aggregations