@Override public String toString() { return "PurchaseExecution [openDate=" + this.openDate() + ", filledDate=" + this.filledDate() + ", quantityOfSharesOrdered=" + this.quantityOfSharesOrdered() + ", quantityOfSharesOutstanding=" + this.quantityOfSharesOutstanding() + "]"; }
public PurchaseExecution withPurchasedSharesOf(int aQuantity) { if (this.wouldOverrunExecutionWith(aQuantity)) { throw new IllegalArgumentException("Acquired too many shares."); } int quantityOfSharesOutstanding = this.quantityOfSharesOutstanding() - aQuantity; return new PurchaseExecution(this.openDate(), this.quantityOfSharesOrdered(), quantityOfSharesOutstanding); }
public void testOpenExecution() throws Exception { PurchaseExecution purchaseExecution = new PurchaseExecution(20); assertEquals(20, purchaseExecution.quantityOfSharesOrdered()); assertEquals(20, purchaseExecution.quantityOfSharesOutstanding()); assertNull(purchaseExecution.filledDate()); assertNotNull(purchaseExecution.openDate()); Calendar openDate = Calendar.getInstance(); openDate.setTime(purchaseExecution.openDate()); assertEquals(Calendar.getInstance().get(Calendar.MONTH), openDate.get(Calendar.MONTH)); assertEquals(Calendar.getInstance().get(Calendar.DATE), openDate.get(Calendar.DATE)); assertEquals(Calendar.getInstance().get(Calendar.YEAR), openDate.get(Calendar.YEAR)); }
public BuyOrder( AccountId anAccountId, Quote aQuote, int aQuantityOfSharesOrdered, Money anOrderFee) { super(); this.setAccountId(anAccountId); this.setExecution(new PurchaseExecution(aQuantityOfSharesOrdered)); this.setOrderId(OrderId.unique()); this.setQuote(aQuote); DomainEventPublisher.instance().publish( new BuyOrderPlaced( this.accountId(), this.orderId(), this.quote(), this.execution().quantityOfSharesOrdered(), this.execution().openDate(), aQuote.price().multipliedBy(aQuantityOfSharesOrdered), anOrderFee)); }