use of name.abuchen.portfolio.snapshot.filter.ClientFilter in project portfolio by buchen.
the class GroupByTaxonomyTest method testThatAccountsAreClassifiedCorrectlyWhenFiltered.
@Test
public void testThatAccountsAreClassifiedCorrectlyWhenFiltered() {
// bug report:
// https://forum.portfolio-performance.info/t/vermoegensaufstellung-klassifizierung-mit-filter/1129
Client client = new Client();
Taxonomy taxonomy = //
new TaxonomyBuilder().addClassification(//
"debt").addTo(client);
Security a = //
new SecurityBuilder().addPrice("2010-01-01", //
Values.Quote.factorize(10)).assign(taxonomy, "debt", //
Classification.ONE_HUNDRED_PERCENT).addTo(client);
Account account = //
new AccountBuilder().deposit_("2010-01-01", Values.Amount.factorize(100)).assign(taxonomy, "debt", //
Classification.ONE_HUNDRED_PERCENT).addTo(client);
//
new PortfolioBuilder(account).inbound_delivery(a, "2010-01-01", Values.Share.factorize(10), //
10000).addTo(client);
ClientFilter filter = new ClientClassificationFilter(taxonomy.getClassificationById("debt"));
LocalDate date = LocalDate.parse("2010-01-01");
ClientSnapshot snapshot = ClientSnapshot.create(filter.filter(client), new TestCurrencyConverter(), date);
assertNotNull(snapshot);
GroupByTaxonomy grouping = snapshot.groupByTaxonomy(taxonomy);
// everything is classified
assertThat(grouping.asList().size(), is(1));
// two positions in 'debt' category
AssetCategory debt = grouping.byClassification(taxonomy.getClassificationById("debt"));
assertThat(debt.getValuation(), is(Money.of(CurrencyUnit.EUR, Values.Money.factorize(200))));
assertThat(debt.getPositions().size(), is(2));
// nothing in unassigned
AssetCategory unassigned = null;
for (AssetCategory category : grouping.asList()) if (category.getClassification().getId().equals(Classification.UNASSIGNED_ID))
unassigned = category;
assertThat(unassigned, nullValue());
}
Aggregations