use of name.abuchen.portfolio.model.Taxonomy in project portfolio by buchen.
the class GroupByTaxonomyTest method testThatPartialAssignmentsAreSeparated.
@Test
public void testThatPartialAssignmentsAreSeparated() {
Client client = new Client();
Taxonomy taxonomy = //
new TaxonomyBuilder().addClassification(//
"debt").addClassification(//
"equity").addTo(client);
Security a = //
new SecurityBuilder().addPrice("2010-01-01", //
Values.Quote.factorize(10)).assign(taxonomy, "debt", //
Classification.ONE_HUNDRED_PERCENT / 2).assign(taxonomy, "equity", //
Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
Portfolio portfolio = //
new PortfolioBuilder().inbound_delivery(a, "2010-01-01", Values.Share.factorize(10), //
10000).addTo(client);
LocalDate date = LocalDate.parse("2010-01-01");
PortfolioSnapshot snapshot = PortfolioSnapshot.create(portfolio, new TestCurrencyConverter(), date);
assertNotNull(snapshot);
GroupByTaxonomy grouping = snapshot.groupByTaxonomy(taxonomy);
AssetCategory debt = grouping.byClassification(taxonomy.getClassificationById("debt"));
assertThat(debt.getValuation(), is(Money.of(CurrencyUnit.EUR, 50_00)));
assertThat(debt.getPositions().size(), is(1));
AssetCategory equity = grouping.byClassification(taxonomy.getClassificationById("equity"));
assertThat(equity.getValuation(), is(Money.of(CurrencyUnit.EUR, 50_00)));
assertThat(equity.getPositions().size(), is(1));
}
use of name.abuchen.portfolio.model.Taxonomy in project portfolio by buchen.
the class ClientEditorSidebar method taxonomyCreateMenuAboutToShow.
private void taxonomyCreateMenuAboutToShow(IMenuManager manager) {
manager.add(new Action(Messages.MenuTaxonomyCreate) {
@Override
public void run() {
String name = askTaxonomyName(Messages.LabelNewTaxonomy);
if (name == null)
return;
Taxonomy taxonomy = new Taxonomy(name);
taxonomy.setRootNode(new Classification(UUID.randomUUID().toString(), name));
addAndOpenTaxonomy(taxonomy);
}
});
manager.add(new Separator());
manager.add(new LabelOnly(Messages.LabelTaxonomyTemplates));
for (final TaxonomyTemplate template : TaxonomyTemplate.list()) {
manager.add(new Action(template.getName()) {
@Override
public void run() {
addAndOpenTaxonomy(template.build());
}
});
}
}
Aggregations