public Purchase create(AggregateId orderId, Client client, Offer offer){
if (! canPurchse(client, offer.getAvailabeItems()))
throw new DomainOperationException(client.getAggregateId(), "client can not purchase");
ArrayList<PurchaseItem> items = new ArrayList<PurchaseItem>(offer.getAvailabeItems().size());
Money purchaseTotlCost = Money.ZERO;
for (OfferItem item : offer.getAvailabeItems()) {
PurchaseItem purchaseItem = new PurchaseItem(item.getProductData(), item.getQuantity(), item.getTotalCost());
items.add(purchaseItem);
purchaseTotlCost = purchaseTotlCost.add(purchaseItem.getTotalCost());
}
Purchase purchase = new Purchase(orderId, client.generateSnapshot(),
items, new Date(), false, purchaseTotlCost);