Exemplo n.º 1
0
  @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;
    }
  }
Exemplo n.º 2
0
 private PortfolioTransaction convertTo(PortfolioTransaction t, PortfolioTransaction.Type type) {
   PortfolioTransaction clone = new PortfolioTransaction();
   clone.setType(type);
   clone.setDate(t.getDate());
   clone.setCurrencyCode(t.getCurrencyCode());
   clone.setSecurity(t.getSecurity());
   clone.setAmount(t.getAmount());
   clone.setShares(t.getShares());
   clone.addUnits(t.getUnits());
   return clone;
 }