@Override public Status process(BuySellEntry entry, Account account, Portfolio portfolio) { if (convertBuySellToDelivery) { PortfolioTransaction t = entry.getPortfolioTransaction(); PortfolioTransaction delivery = new PortfolioTransaction(); delivery.setType( t.getType() == PortfolioTransaction.Type.BUY ? PortfolioTransaction.Type.DELIVERY_INBOUND : PortfolioTransaction.Type.DELIVERY_OUTBOUND); delivery.setDate(t.getDate()); delivery.setSecurity(t.getSecurity()); delivery.setMonetaryAmount(t.getMonetaryAmount()); delivery.setNote(t.getNote()); delivery.setShares(t.getShares()); delivery.addUnits(t.getUnits()); return process(delivery, portfolio); } else { entry.setPortfolio(portfolio); entry.setAccount(account); entry.insert(); return Status.OK_STATUS; } }
@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); }