Search in sources :

Example 1 with Issue

use of name.abuchen.portfolio.checks.Issue in project portfolio by buchen.

the class CrossEntryCheckTest method testMissingAccountTransferInIssue.

@Test
public void testMissingAccountTransferInIssue() {
    account.addTransaction(new AccountTransaction(LocalDateTime.now(), CurrencyUnit.EUR, 1, security, AccountTransaction.Type.TRANSFER_OUT));
    List<Issue> issues = new CrossEntryCheck().execute(client);
    assertThat(issues.size(), is(1));
    assertThat(issues.get(0), is(instanceOf(MissingAccountTransferIssue.class)));
    assertThat(issues.get(0).getEntity(), is((Object) account));
    applyFixes(client, issues);
}
Also used : Issue(name.abuchen.portfolio.checks.Issue) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Test(org.junit.Test)

Example 2 with Issue

use of name.abuchen.portfolio.checks.Issue in project portfolio by buchen.

the class CrossEntryCheckTest method testThatAlmostMatchingBuySellEntriesAreNotMatched.

@Test
public void testThatAlmostMatchingBuySellEntriesAreNotMatched() {
    LocalDateTime date = LocalDateTime.now();
    portfolio.addTransaction(new PortfolioTransaction(date, CurrencyUnit.EUR, 1, security, 1, PortfolioTransaction.Type.SELL, 1, 0));
    account.addTransaction(new AccountTransaction(date, CurrencyUnit.EUR, 2, security, AccountTransaction.Type.SELL));
    List<Issue> issues = new CrossEntryCheck().execute(client);
    assertThat(issues.size(), is(2));
    List<Object> objects = new ArrayList<Object>(issues);
    assertThat(objects, hasItem(instanceOf(MissingBuySellAccountIssue.class)));
    assertThat(objects, hasItem(instanceOf(MissingBuySellPortfolioIssue.class)));
    applyFixes(client, issues);
}
Also used : LocalDateTime(java.time.LocalDateTime) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Issue(name.abuchen.portfolio.checks.Issue) ArrayList(java.util.ArrayList) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Test(org.junit.Test)

Example 3 with Issue

use of name.abuchen.portfolio.checks.Issue in project portfolio by buchen.

the class CrossEntryCheckTest method testMissingPortfolioTransferInIssue.

@Test
public void testMissingPortfolioTransferInIssue() {
    portfolio.addTransaction(new PortfolioTransaction(LocalDateTime.now(), CurrencyUnit.EUR, 1, security, 1, PortfolioTransaction.Type.TRANSFER_OUT, 1, 0));
    List<Issue> issues = new CrossEntryCheck().execute(client);
    assertThat(issues.size(), is(1));
    assertThat(issues.get(0), is(instanceOf(MissingPortfolioTransferIssue.class)));
    assertThat(issues.get(0).getEntity(), is((Object) portfolio));
    applyFixes(client, issues);
}
Also used : PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Issue(name.abuchen.portfolio.checks.Issue) Test(org.junit.Test)

Example 4 with Issue

use of name.abuchen.portfolio.checks.Issue in project portfolio by buchen.

the class CrossEntryCheckTest method testThatNotTheSamePortfolioIsMatched.

@Test
public void testThatNotTheSamePortfolioIsMatched() {
    Portfolio second = new Portfolio();
    client.addPortfolio(second);
    LocalDateTime date = LocalDateTime.now();
    portfolio.addTransaction(new PortfolioTransaction(date, CurrencyUnit.EUR, 3, security, 1, PortfolioTransaction.Type.TRANSFER_IN, 1, 0));
    PortfolioTransaction umatched = new PortfolioTransaction(date, CurrencyUnit.EUR, 3, security, 1, PortfolioTransaction.Type.TRANSFER_OUT, 1, 0);
    portfolio.addTransaction(umatched);
    second.addTransaction(new PortfolioTransaction(date, CurrencyUnit.EUR, 3, security, 1, PortfolioTransaction.Type.TRANSFER_OUT, 1, 0));
    List<Issue> issues = new CrossEntryCheck().execute(client);
    assertThat(issues.size(), is(1));
    assertThat(issues.get(0), is(instanceOf(MissingPortfolioTransferIssue.class)));
    assertThat(portfolio.getTransactions(), hasItem(umatched));
    assertThat(second.getTransactions().get(0).getCrossEntry(), notNullValue());
    assertThat(second.getTransactions().get(0).getType(), is(PortfolioTransaction.Type.TRANSFER_OUT));
    applyFixes(client, issues);
}
Also used : LocalDateTime(java.time.LocalDateTime) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Issue(name.abuchen.portfolio.checks.Issue) Portfolio(name.abuchen.portfolio.model.Portfolio) Test(org.junit.Test)

Example 5 with Issue

use of name.abuchen.portfolio.checks.Issue in project portfolio by buchen.

the class CrossEntryCheckTest method applyFixes.

private void applyFixes(Client client, List<Issue> issues) {
    for (Issue issue : issues) {
        List<QuickFix> fixes = issue.getAvailableFixes();
        assertThat(fixes.isEmpty(), is(false));
        fixes.get(0).execute();
    }
    assertThat(new CrossEntryCheck().execute(client).size(), is(0));
}
Also used : QuickFix(name.abuchen.portfolio.checks.QuickFix) Issue(name.abuchen.portfolio.checks.Issue)

Aggregations

Issue (name.abuchen.portfolio.checks.Issue)13 Test (org.junit.Test)10 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)8 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)6 Portfolio (name.abuchen.portfolio.model.Portfolio)4 LocalDateTime (java.time.LocalDateTime)3 ArrayList (java.util.ArrayList)3 QuickFix (name.abuchen.portfolio.checks.QuickFix)2 Account (name.abuchen.portfolio.model.Account)2 MessageFormat (java.text.MessageFormat)1 LocalDate (java.time.LocalDate)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Messages (name.abuchen.portfolio.Messages)1 TestCurrencyConverter (name.abuchen.portfolio.TestCurrencyConverter)1 Check (name.abuchen.portfolio.checks.Check)1 AccountTransferEntry (name.abuchen.portfolio.model.AccountTransferEntry)1 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)1