Package pl.com.bottega.ecommerce.sharedkernel

Examples of pl.com.bottega.ecommerce.sharedkernel.Money


  @EventListener
  public void handle(CustomerStatusChangedEvent event){
    OrderQuery orderQuery = new OrderQuery(null, event.getCustomerId());
    PaginatedResult<OrderDto> orders = orderFinder.query(orderQuery);
   
    Money discount = calculateDiscout(event.getCustomerId());
   
    for(OrderDto dto : orders.getItems()){
      discountingService.applyDiscount(dto.getOrderId(), discount);
    }
  }
View Full Code Here


    }
  }

  private Money calculateDiscout(AggregateId customerId) {
    // TODO explore domain rules
    return new Money(10);
  }
View Full Code Here

  public OfferItem(ProductData productData, int quantity, Discount discount) {
    this.productData = productData;
    this.quantity = quantity;
    this.discount = discount;
   
    Money discountValue = Money.ZERO;
    if (discount != null)
       discountValue =  discountValue.subtract(discount.getValue());
   
    this.totalCost = productData.getPrice().multiplyBy(quantity).subtract(discountValue);
  }
View Full Code Here

   
    if (quantity != item.quantity)
      return false;
   
   
    Money max, min;
    if (totalCost.greaterThan(item.totalCost)){
      max = totalCost;
      min = item.totalCost;
    }
    else{
      max = item.totalCost;
      min = totalCost;
    }
   
    Money difference = max.subtract(min);
    Money acceptableDelta = max.multiplyBy(delta / 100);
   
    return acceptableDelta.greaterThan(difference);
  }
View Full Code Here

          new SameCategory(problematicProduct.getProductType()));
  }

  private Money generateAcceptableDifference(Client client) {
    // TODO explore rules
    return new Money(7);
  }
View Full Code Here

  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);
   
View Full Code Here

 
  public Invoice issuance(InvoiceRequest invoiceRequest, TaxPolicy taxPolicy){
    Invoice invoice = invoiceFactory.create(invoiceRequest.getClientData());
   
    for (RequestItem item : invoiceRequest.getItems()){
      Money net = item.getTotalCost();     
      Tax tax = taxPolicy.calculateTax(item.getProductData().getType(), net);     
           
      InvoiceLine invoiceLine = new InvoiceLine(item.getProductData(), item.getQuantity(), net, tax);     
      invoice.addItem(invoiceLine);
    }
View Full Code Here

  }
 
  @Override
  public Tax calculateTax(ProductType productType, Money net) {
    String desc = "sorry";       
    Money tax = net.multiplyBy(ratio);
    return new Tax(tax, desc);
  }
View Full Code Here

     
    default:
      throw new IllegalArgumentException(productType + " not handled");
    }
       
    Money tax = net.multiplyBy(ratio);
   
    return new Tax(tax, desc);
  }
View Full Code Here

import pl.com.bottega.ecommerce.sharedkernel.Money;

public class ProductObjectMother {

  public static Product someProduct(){
    return new Product(AggregateId.generate(), new Money(10.0), "product 1", ProductType.STANDARD);
  }
View Full Code Here

TOP

Related Classes of pl.com.bottega.ecommerce.sharedkernel.Money

Copyright © 2018 www.massapicom. 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.