use of name.abuchen.portfolio.snapshot.filter.PortfolioClientFilter 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.filter.PortfolioClientFilter in project portfolio by buchen.
the class ClientFilterMenu method buildItem.
private Item buildItem(Object[] selected) {
List<Portfolio> portfolios = Arrays.stream(selected).filter(o -> o instanceof Portfolio).map(o -> (Portfolio) o).collect(Collectors.toList());
List<Account> accounts = Arrays.stream(selected).filter(o -> o instanceof Account).map(o -> (Account) o).collect(Collectors.toList());
String label = // $NON-NLS-1$
String.join(// $NON-NLS-1$
", ", Arrays.stream(selected).map(String::valueOf).collect(Collectors.toList()));
String uuids = // $NON-NLS-1$
String.join(// $NON-NLS-1$
",", Arrays.stream(selected).map(o -> o instanceof Account ? ((Account) o).getUUID() : ((Portfolio) o).getUUID()).collect(Collectors.toList()));
return new Item(label, uuids, new PortfolioClientFilter(portfolios, accounts));
}
Aggregations