Example #1
0
  @Test
  public void testThatAlmostMatchingBuySellEntriesAreNotMatched() {
    portfolio.addTransaction(
        new PortfolioTransaction(
            Dates.today(),
            security, //
            PortfolioTransaction.Type.SELL,
            1,
            1,
            1));

    account.addTransaction(
        new AccountTransaction(
            Dates.today(),
            security, //
            AccountTransaction.Type.SELL,
            2));

    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);
  }
Example #2
0
 @Override
 public Status process(AccountTransaction transaction, Account account) {
   // ensure consistency (in case the user deleted the creation of the
   // security via the dialog)
   if (transaction.getSecurity() != null) process(transaction.getSecurity());
   account.addTransaction(transaction);
   return Status.OK_STATUS;
 }
Example #3
0
  @Test
  public void testThatNotTheSameAccountIsMatched() {
    Account second = new Account();
    client.addAccount(second);

    account.addTransaction(
        new AccountTransaction(
            Dates.today(),
            security, //
            AccountTransaction.Type.TRANSFER_IN,
            2));

    AccountTransaction umatched =
        new AccountTransaction(
            Dates.today(),
            security, //
            AccountTransaction.Type.TRANSFER_OUT,
            2);
    account.addTransaction(umatched);

    second.addTransaction(
        new AccountTransaction(
            Dates.today(),
            security, //
            AccountTransaction.Type.TRANSFER_OUT,
            2));

    List<Issue> issues = new CrossEntryCheck().execute(client);

    assertThat(issues.size(), is(1));
    assertThat(issues.get(0), is(MissingAccountTransferIssue.class));

    assertThat(account.getTransactions(), hasItem(umatched));
    assertThat(second.getTransactions().get(0).getCrossEntry(), notNullValue());
    assertThat(second.getTransactions().get(0).getType(), is(AccountTransaction.Type.TRANSFER_OUT));

    applyFixes(client, issues);
  }
Example #4
0
  @Test
  public void testMissingAccountTransferInIssue() {
    account.addTransaction(
        new AccountTransaction(
            Dates.today(),
            security, //
            AccountTransaction.Type.TRANSFER_OUT,
            1));

    List<Issue> issues = new CrossEntryCheck().execute(client);

    assertThat(issues.size(), is(1));
    assertThat(issues.get(0), is(MissingAccountTransferIssue.class));
    assertThat(issues.get(0).getEntity(), is((Object) account));

    applyFixes(client, issues);
  }
Example #5
0
  @Test
  public void testThatAccountTransactionsWithoutSecurity() {
    Portfolio second = new Portfolio();
    client.addPortfolio(second);

    account.addTransaction(
        new AccountTransaction(
            Dates.today(),
            null, //
            AccountTransaction.Type.BUY,
            1));

    List<Issue> issues = new CrossEntryCheck().execute(client);

    assertThat(issues.size(), is(1));
    assertThat(issues.get(0).getAvailableFixes().get(0), is(DeleteTransactionFix.class));

    applyFixes(client, issues);

    ClientSnapshot.create(client, Dates.today());
  }
Example #6
0
  @Test
  public void testThatMatchingBuySellEntriesAreFixed() {
    portfolio.addTransaction(
        new PortfolioTransaction(
            Dates.today(),
            security, //
            PortfolioTransaction.Type.SELL,
            1,
            1,
            1));

    account.addTransaction(
        new AccountTransaction(
            Dates.today(),
            security, //
            AccountTransaction.Type.SELL,
            1));

    assertThat(new CrossEntryCheck().execute(client).size(), is(0));
    assertThat(portfolio.getTransactions().get(0).getCrossEntry(), notNullValue());
    assertThat(account.getTransactions().get(0).getCrossEntry(), notNullValue());
  }