use of name.abuchen.portfolio.snapshot.ClientSnapshot in project portfolio by buchen.
the class CurrencyTestCase method testFIFOPurchasePriceWithForex.
@Test
public void testFIFOPurchasePriceWithForex() {
ClientSnapshot snapshot = ClientSnapshot.create(client, converter, LocalDate.parse("2015-08-09"));
// 1.1. ........ -> 454.60 EUR
// 1.1. 571.90 $ -> 471.05 EUR (exchange rate: 1.2141)
// 3.8. 577.60 $ -> 498.45 EUR (exchange rate: 1.1588)
AssetPosition position = snapshot.getPositionsByVehicle().get(securityUSD);
assertThat(position.getPosition().getShares(), is(Values.Share.factorize(15)));
assertThat(position.getFIFOPurchaseValue(), is(Money.of(CurrencyUnit.EUR, 454_60 + 471_05 + 498_45)));
ReportingPeriod period = new ReportingPeriod.FromXtoY(LocalDate.parse("2014-12-31"), LocalDate.parse("2015-08-10"));
SecurityPerformanceSnapshot performance = SecurityPerformanceSnapshot.create(client, converter, period);
SecurityPerformanceRecord record = performance.getRecords().stream().filter(r -> r.getSecurity() == securityUSD).findAny().get();
assertThat(record.getSharesHeld(), is(Values.Share.factorize(15)));
assertThat(record.getFifoCost(), is(Money.of(CurrencyUnit.EUR, 454_60 + 471_05 + 498_45)));
}
use of name.abuchen.portfolio.snapshot.ClientSnapshot in project portfolio by buchen.
the class SecurityTaxAndFeeAccountTransactionsTestCase method checkFilteredClientAdidas.
private void checkFilteredClientAdidas(Client filteredClient, double weight) {
List<AccountTransaction> txa = filteredClient.getAccounts().stream().flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
// expect 4 transactions: the two fees-related ones plus the
// deposit/removal to have the account balance at zero
assertThat(txa.size(), is(4));
// check balance is zero
ClientSnapshot balance = ClientSnapshot.create(filteredClient, converter, interval.getEndDate());
assertThat(balance.getMonetaryAssets(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(1456.5 * weight))));
assertThat(balance.getAccounts().size(), is(1));
assertThat(balance.getAccounts().iterator().next().getFunds(), is(Money.of(CurrencyUnit.EUR, 0)));
// check for additional transactions
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2017-01-09T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10.0 * weight)))))));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2017-01-10T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5.0 * weight)))))));
}
use of name.abuchen.portfolio.snapshot.ClientSnapshot in project portfolio by buchen.
the class SecurityTaxAndFeeAccountTransactionsTestCase method checkPortfolioClientFilter.
@Test
public void checkPortfolioClientFilter() {
Client filteredClient = new PortfolioClientFilter(client.getPortfolios().get(0)).filter(client);
List<AccountTransaction> txa = filteredClient.getAccounts().stream().flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
// expect 8 transactions: the 4 tax and fees transactions plus the
// offset transactions to keep the balance zero
assertThat(txa.size(), is(8));
// check balance is zero
ClientSnapshot balance = ClientSnapshot.create(filteredClient, converter, interval.getEndDate());
assertThat(balance.getMonetaryAssets(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(1456.5))));
assertThat(balance.getAccounts().size(), is(1));
assertThat(balance.getAccounts().iterator().next().getFunds(), is(Money.of(CurrencyUnit.EUR, 0)));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2017-01-09T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10.0)))))));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2017-01-10T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5.0)))))));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2017-01-11T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(25.0)))))));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2017-01-12T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5.0)))))));
}
use of name.abuchen.portfolio.snapshot.ClientSnapshot in project portfolio by buchen.
the class StatementOfAssetsView method notifyModelUpdated.
@Override
public void notifyModelUpdated() {
CurrencyConverter converter = new CurrencyConverterImpl(factory, getClient().getBaseCurrency());
Client filteredClient = clientFilter.getSelectedFilter().filter(getClient());
ClientSnapshot snapshot = ClientSnapshot.create(filteredClient, converter, snapshotDate);
assetViewer.setInput(snapshot, clientFilter.getSelectedFilter());
updateTitle(getDefaultTitle());
}
use of name.abuchen.portfolio.snapshot.ClientSnapshot in project portfolio by buchen.
the class TaxonomyView method notifyModelUpdated.
@Override
public void notifyModelUpdated() {
Client filteredClient = this.clientFilter.filter(getClient());
ClientSnapshot snapshot = ClientSnapshot.create(filteredClient, model.getCurrencyConverter(), LocalDate.now());
model.setClientSnapshot(filteredClient, snapshot);
model.fireTaxonomyModelChange(model.getVirtualRootNode());
}
Aggregations