Search in sources :

Example 31 with Taxonomy

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));
}
Also used : TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Taxonomy(name.abuchen.portfolio.model.Taxonomy) Portfolio(name.abuchen.portfolio.model.Portfolio) PortfolioBuilder(name.abuchen.portfolio.PortfolioBuilder) Client(name.abuchen.portfolio.model.Client) Security(name.abuchen.portfolio.model.Security) LocalDate(java.time.LocalDate) TaxonomyBuilder(name.abuchen.portfolio.TaxonomyBuilder) SecurityBuilder(name.abuchen.portfolio.SecurityBuilder) Test(org.junit.Test)

Example 32 with Taxonomy

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());
            }
        });
    }
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Taxonomy(name.abuchen.portfolio.model.Taxonomy) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) Classification(name.abuchen.portfolio.model.Classification) TaxonomyTemplate(name.abuchen.portfolio.model.TaxonomyTemplate) Separator(org.eclipse.jface.action.Separator)

Aggregations

Taxonomy (name.abuchen.portfolio.model.Taxonomy)32 Client (name.abuchen.portfolio.model.Client)25 Security (name.abuchen.portfolio.model.Security)24 LocalDate (java.time.LocalDate)22 Test (org.junit.Test)22 TestCurrencyConverter (name.abuchen.portfolio.TestCurrencyConverter)21 Classification (name.abuchen.portfolio.model.Classification)19 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)17 Collectors (java.util.stream.Collectors)17 List (java.util.List)16 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)16 ClientFactory (name.abuchen.portfolio.model.ClientFactory)16 Values (name.abuchen.portfolio.money.Values)16 PerformanceIndex (name.abuchen.portfolio.snapshot.PerformanceIndex)16 ReportingPeriod (name.abuchen.portfolio.snapshot.ReportingPeriod)16 ClientClassificationFilter (name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter)16 LocalDateTime (java.time.LocalDateTime)15 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)15 Money (name.abuchen.portfolio.money.Money)15