Exemplo n.º 1
0
  @Test
  public void testThatCorrectBuySellEntriesAreNotReported() {
    BuySellEntry entry = new BuySellEntry(portfolio, account);
    entry.setType(PortfolioTransaction.Type.BUY);
    entry.setDate(Dates.today());
    entry.setSecurity(security);
    entry.setShares(1);
    entry.setAmount(100);
    entry.insert();

    assertThat(new CrossEntryCheck().execute(client).size(), is(0));
  }
    @Override
    public void execute() {
      BuySellEntry entry = new BuySellEntry(portfolio, account);
      entry.setDate(transaction.getDate());
      entry.setType(PortfolioTransaction.Type.valueOf(transaction.getType().name()));
      entry.setSecurity(transaction.getSecurity());
      entry.setShares(Values.Share.factor());
      entry.setAmount(transaction.getAmount());
      entry.setCurrencyCode(transaction.getCurrencyCode());
      entry.insert();

      account.getTransactions().remove(transaction);
    }