Search in sources :

Example 11 with Taxonomy

use of name.abuchen.portfolio.model.Taxonomy in project portfolio by buchen.

the class GroupByTaxonomyTest method testThatSecuritiesAreGroupedIntoClassifications.

@Test
public void testThatSecuritiesAreGroupedIntoClassifications() {
    Client client = new Client();
    Taxonomy taxonomy = // 
    new TaxonomyBuilder().addClassification(// 
    "debt").addClassification(// 
    "equity").addClassification(// 
    "realestate").addTo(client);
    Security a = // 
    new SecurityBuilder().addPrice("2010-01-01", // 
    Values.Quote.factorize(10)).assign(taxonomy, // 
    "debt").addTo(client);
    Security c = // 
    new SecurityBuilder().addPrice("2010-01-01", // 
    Values.Quote.factorize(12)).assign(taxonomy, // 
    "equity").addTo(client);
    Security d = // 
    new SecurityBuilder().addPrice("2010-01-01", // 
    Values.Quote.factorize(12)).assign(taxonomy, // 
    "equity").addTo(client);
    Portfolio portfolio = // 
    new PortfolioBuilder().inbound_delivery(a, "2010-01-01", Values.Share.factorize(10), // 
    10000).inbound_delivery(c, "2010-01-01", Values.Share.factorize(10), // 
    12000).inbound_delivery(d, "2010-01-01", Values.Share.factorize(10), // 
    12000).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, 100_00)));
    assertThat(debt.getPositions().size(), is(1));
    AssetCategory stocks = grouping.byClassification(taxonomy.getClassificationById("equity"));
    assertThat(stocks.getValuation(), is(Money.of(CurrencyUnit.EUR, 240_00)));
    assertThat(stocks.getPositions().size(), is(2));
    AssetCategory realEstate = grouping.byClassification(taxonomy.getClassificationById("realestate"));
    assertThat(realEstate, nullValue());
}
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 12 with Taxonomy

use of name.abuchen.portfolio.model.Taxonomy in project portfolio by buchen.

the class GroupByTaxonomyTest method testSecuritiesWithoutAssignment.

@Test
public void testSecuritiesWithoutAssignment() {
    Client client = new Client();
    Taxonomy taxonomy = // 
    new TaxonomyBuilder().addClassification(// 
    "debt").addTo(client);
    Security a = // 
    new SecurityBuilder().addPrice("2010-01-01", // 
    Values.Quote.factorize(10)).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, nullValue());
    List<AssetCategory> categories = grouping.asList();
    assertThat(categories.size(), is(1));
    AssetCategory unassigned = categories.get(0);
    assertThat(unassigned.getValuation(), is(Money.of(CurrencyUnit.EUR, 100_00)));
    assertThat(unassigned.getPositions().size(), is(1));
}
Also used : Taxonomy(name.abuchen.portfolio.model.Taxonomy) Portfolio(name.abuchen.portfolio.model.Portfolio) PortfolioBuilder(name.abuchen.portfolio.PortfolioBuilder) Security(name.abuchen.portfolio.model.Security) LocalDate(java.time.LocalDate) TaxonomyBuilder(name.abuchen.portfolio.TaxonomyBuilder) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Client(name.abuchen.portfolio.model.Client) SecurityBuilder(name.abuchen.portfolio.SecurityBuilder) Test(org.junit.Test)

Example 13 with Taxonomy

use of name.abuchen.portfolio.model.Taxonomy in project portfolio by buchen.

the class GroupByTaxonomyTest method testThatPartialAssignmentsInSubClassificationsAreMerged.

@Test
public void testThatPartialAssignmentsInSubClassificationsAreMerged() {
    Client client = new Client();
    Taxonomy taxonomy = // 
    new TaxonomyBuilder().addClassification(// 
    "debt").addClassification("debt", // 
    "cat1").addClassification("debt", // 
    "cat2").addTo(client);
    Security a = // 
    new SecurityBuilder().addPrice("2010-01-01", // 
    Values.Quote.factorize(10)).assign(taxonomy, "cat1", // 
    Classification.ONE_HUNDRED_PERCENT / 2).assign(taxonomy, "cat2", // 
    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);
    assertThat(grouping.asList().size(), is(1));
    AssetCategory debt = grouping.byClassification(taxonomy.getClassificationById("debt"));
    assertThat(debt.getPositions().size(), is(1));
    assertThat(debt.getValuation(), is(Money.of(CurrencyUnit.EUR, 100_00)));
}
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 14 with Taxonomy

use of name.abuchen.portfolio.model.Taxonomy in project portfolio by buchen.

the class ClientEditorSidebar method createTaxonomyDataSection.

private void createTaxonomyDataSection(final Sidebar sidebar) {
    taxonomies = new Entry(sidebar, Messages.LabelTaxonomies);
    taxonomies.setAction(new Action(Messages.LabelTaxonomies, Images.PLUS.descriptor()) {

        @Override
        public void run() {
            showCreateTaxonomyMenu();
        }
    });
    for (Taxonomy taxonomy : editor.getClient().getTaxonomies()) createTaxonomyEntry(taxonomies, taxonomy);
}
Also used : Entry(name.abuchen.portfolio.ui.Sidebar.Entry) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Taxonomy(name.abuchen.portfolio.model.Taxonomy)

Example 15 with Taxonomy

use of name.abuchen.portfolio.model.Taxonomy in project portfolio by buchen.

the class ClientEditorSidebar method addMoveUpAndDownActions.

private void addMoveUpAndDownActions(Taxonomy taxonomy, Entry entry, IMenuManager manager) {
    List<Taxonomy> list = editor.getClient().getTaxonomies();
    int size = list.size();
    int index = list.indexOf(taxonomy);
    if (index > 0) {
        manager.add(new Action(Messages.MenuMoveUp) {

            @Override
            public void run() {
                Client client = editor.getClient();
                client.removeTaxonomy(taxonomy);
                client.addTaxonomy(index - 1, taxonomy);
                client.markDirty();
                entry.moveUp();
                sidebar.layout();
            }
        });
    }
    if (index < size - 1 && size > 1) {
        manager.add(new Action(Messages.MenuMoveDown) {

            @Override
            public void run() {
                Client client = editor.getClient();
                client.removeTaxonomy(taxonomy);
                client.addTaxonomy(index + 1, taxonomy);
                client.markDirty();
                entry.findNeighbor(SWT.ARROW_DOWN).moveUp();
                sidebar.layout();
            }
        });
    }
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Taxonomy(name.abuchen.portfolio.model.Taxonomy) Client(name.abuchen.portfolio.model.Client)

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