Examples of Purchase


Examples of pl.com.bottega.ecommerce.sales.domain.purchase.Purchase

  @Inject
  private InvoiceRequestFactory invoiceRequestFactory;
 
  @EventListener
  public void handle(OrderSubmittedEvent event){
    Purchase purchase = purchaseRepository.load(event.getOrderId());
   
    Client client = clientRepository.load(purchase.getClientData().getAggregateId());
    InvoiceRequest request  = invoiceRequestFactory.create(client, purchase);
    Invoice invoice = bookKeeper.issuance(request, taxAdvisor.suggestBestTax(client));
   
    invoiceRepository.save(invoice);
  }
View Full Code Here

Examples of pl.com.bottega.ecommerce.sales.domain.purchase.Purchase

  private EntityManager entityManager;

  @Override
  public OrderDto find(AggregateId orderId) {
    Reservation reservation = entityManager.find(Reservation.class, orderId);
    Purchase purchase = entityManager.find(Purchase.class, orderId);
   
    return toOrderDto(reservation, purchase);
  }
View Full Code Here

Examples of pl.com.bottega.ecommerce.sales.domain.purchase.Purchase

     */
    if (! newOffer.sameAs(seenOffer, 5))//TODO load delta from conf.
      throw new OfferChangedExcpetion(reservation.getAggregateId(), seenOffer, newOffer);
   
    Client client = loadClient();//create per logged client, not reservation owner         
    Purchase purchase = purchaseFactory.create(reservation.getAggregateId(), client, seenOffer);
       
    if (! client.canAfford(purchase.getTotalCost()))
      throw new DomainOperationException(client.getAggregateId(), "client has insufficent money");
   
    purchaseRepository.save(purchase);//Aggregate must be managed by persistence context before firing events (synchronous listeners may need to load it)
   
    /*
     * Sample model where one aggregate creates another. Client does not manage payment lifecycle, therefore application must manage it.
     */
    Payment payment = client.charge(purchase.getTotalCost());
    paymentRepository.save(payment);
   
    purchase.confirm()
    reservation.close();       
   
    reservationRepository.save(reservation);
    clientRepository.save(client);
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.