Search in sources :

Example 26 with Classification

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

the class ClassificationIndexTest method testThat100PercentAssignmentIsIdenticalToClientPerformance.

@Test
public void testThat100PercentAssignmentIsIdenticalToClientPerformance() {
    Client client = createClient(Classification.ONE_HUNDRED_PERCENT);
    Classification classification = client.getTaxonomies().get(0).getClassificationById("one");
    List<Exception> warnings = new ArrayList<Exception>();
    CurrencyConverter converter = new TestCurrencyConverter();
    PerformanceIndex iClient = PerformanceIndex.forClient(client, converter, period, warnings);
    PerformanceIndex iClassification = PerformanceIndex.forClassification(client, converter, classification, period, warnings);
    assertThat(warnings.isEmpty(), is(true));
    assertThat(iClient.getDates(), is(iClassification.getDates()));
    assertThat(iClient.getAccumulatedPercentage(), is(iClassification.getAccumulatedPercentage()));
    assertThat(iClient.getDeltaPercentage(), is(iClassification.getDeltaPercentage()));
    assertThat(iClient.getTotals(), is(iClassification.getTotals()));
    assertThat(iClient.getTransferals(), is(iClassification.getTransferals()));
}
Also used : TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Classification(name.abuchen.portfolio.model.Classification) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) Test(org.junit.Test)

Example 27 with Classification

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

the class ClassificationIndexTest method testThat50PercentAssignmentHasIdenticalPerformanceButOnly50PercentTotals.

@Test
public void testThat50PercentAssignmentHasIdenticalPerformanceButOnly50PercentTotals() {
    Client client = createClient(Classification.ONE_HUNDRED_PERCENT / 2);
    Classification classification = client.getTaxonomies().get(0).getClassificationById("one");
    List<Exception> warnings = new ArrayList<Exception>();
    CurrencyConverter converter = new TestCurrencyConverter();
    PerformanceIndex iClient = PerformanceIndex.forClient(client, converter, period, warnings);
    PerformanceIndex iClassification = PerformanceIndex.forClassification(client, converter, classification, period, warnings);
    assertThat(warnings.isEmpty(), is(true));
    assertThat(iClient.getDates(), is(iClassification.getDates()));
    assertThat(iClient.getAccumulatedPercentage(), is(iClassification.getAccumulatedPercentage()));
    assertThat(iClient.getDeltaPercentage(), is(iClassification.getDeltaPercentage()));
    assertThat(half(iClient.getTotals()), is(iClassification.getTotals()));
    assertThat(half(iClient.getTransferals()), is(iClassification.getTransferals()));
}
Also used : TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Classification(name.abuchen.portfolio.model.Classification) ArrayList(java.util.ArrayList) Client(name.abuchen.portfolio.model.Client) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) Test(org.junit.Test)

Example 28 with Classification

use of name.abuchen.portfolio.model.Classification 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)

Example 29 with Classification

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

the class SecurityBuilder method assign.

public SecurityBuilder assign(Taxonomy taxonomy, String id, int weight) {
    Classification classification = taxonomy.getClassificationById(id);
    classification.addAssignment(new Assignment(security, weight));
    return this;
}
Also used : Assignment(name.abuchen.portfolio.model.Classification.Assignment) Classification(name.abuchen.portfolio.model.Classification)

Example 30 with Classification

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

the class TaxonomyBuilder method addClassificaiton.

private TaxonomyBuilder addClassificaiton(Classification parent, String id) {
    Classification c = new Classification(parent, id, id);
    parent.addChild(c);
    return this;
}
Also used : Classification(name.abuchen.portfolio.model.Classification)

Aggregations

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