Search in sources :

Example 1 with DiscreteOrderItemFeePrice

use of org.broadleafcommerce.core.order.domain.DiscreteOrderItemFeePrice in project BroadleafCommerce by BroadleafCommerce.

the class OrderItemServiceImpl method createDynamicPriceDiscreteOrderItem.

@Override
public DiscreteOrderItem createDynamicPriceDiscreteOrderItem(final DiscreteOrderItemRequest itemRequest, @SuppressWarnings("rawtypes") HashMap skuPricingConsiderations) {
    final DiscreteOrderItem item = (DiscreteOrderItem) orderItemDao.create(OrderItemType.EXTERNALLY_PRICED);
    populateDiscreteOrderItem(item, itemRequest);
    SkuPriceWrapper wrapper = new SkuPriceWrapper(itemRequest.getSku());
    DynamicSkuPrices prices = dynamicSkuPricingService.getSkuPrices(wrapper, skuPricingConsiderations);
    item.setBundleOrderItem(itemRequest.getBundleOrderItem());
    item.setBaseRetailPrice(prices.getRetailPrice());
    item.setBaseSalePrice(prices.getSalePrice());
    item.setSalePrice(prices.getSalePrice());
    item.setRetailPrice(prices.getRetailPrice());
    if (itemRequest.getSalePriceOverride() != null) {
        item.setSalePriceOverride(Boolean.TRUE);
        item.setSalePrice(itemRequest.getSalePriceOverride());
        item.setBaseSalePrice(itemRequest.getSalePriceOverride());
    }
    if (itemRequest.getRetailPriceOverride() != null) {
        item.setRetailPriceOverride(Boolean.TRUE);
        item.setRetailPrice(itemRequest.getRetailPriceOverride());
        item.setBaseRetailPrice(itemRequest.getRetailPriceOverride());
    }
    item.setDiscreteOrderItemFeePrices(itemRequest.getDiscreteOrderItemFeePrices());
    for (DiscreteOrderItemFeePrice fee : itemRequest.getDiscreteOrderItemFeePrices()) {
        item.setSalePrice(item.getSalePrice().add(fee.getAmount()));
        item.setRetailPrice(item.getRetailPrice().add(fee.getAmount()));
    }
    item.setPersonalMessage(itemRequest.getPersonalMessage());
    applyAdditionalOrderItemProperties(item);
    return item;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) SkuPriceWrapper(org.broadleafcommerce.core.catalog.domain.pricing.SkuPriceWrapper) DynamicSkuPrices(org.broadleafcommerce.core.catalog.service.dynamic.DynamicSkuPrices) DiscreteOrderItemFeePrice(org.broadleafcommerce.core.order.domain.DiscreteOrderItemFeePrice)

Example 2 with DiscreteOrderItemFeePrice

use of org.broadleafcommerce.core.order.domain.DiscreteOrderItemFeePrice in project BroadleafCommerce by BroadleafCommerce.

the class OrderItemServiceImpl method createDiscreteOrderItem.

@Override
public DiscreteOrderItem createDiscreteOrderItem(final DiscreteOrderItemRequest itemRequest) {
    final DiscreteOrderItem item = (DiscreteOrderItem) orderItemDao.create(OrderItemType.DISCRETE);
    populateDiscreteOrderItem(item, itemRequest);
    item.setBundleOrderItem(itemRequest.getBundleOrderItem());
    if (itemRequest.getSalePriceOverride() != null) {
        item.setBaseSalePrice(itemRequest.getSalePriceOverride());
    }
    item.setDiscreteOrderItemFeePrices(itemRequest.getDiscreteOrderItemFeePrices());
    if (itemRequest.getSalePriceOverride() != null) {
        item.setSalePriceOverride(Boolean.TRUE);
        item.setSalePrice(itemRequest.getSalePriceOverride());
        item.setBaseSalePrice(itemRequest.getSalePriceOverride());
    }
    if (itemRequest.getRetailPriceOverride() != null) {
        item.setRetailPriceOverride(Boolean.TRUE);
        item.setRetailPrice(itemRequest.getRetailPriceOverride());
        item.setBaseRetailPrice(itemRequest.getRetailPriceOverride());
    }
    for (DiscreteOrderItemFeePrice feePrice : item.getDiscreteOrderItemFeePrices()) {
        feePrice.setDiscreteOrderItem(item);
    }
    if (MapUtils.isNotEmpty(itemRequest.getAdditionalAttributes())) {
        item.setAdditionalAttributes(itemRequest.getAdditionalAttributes());
    }
    item.setPersonalMessage(itemRequest.getPersonalMessage());
    applyAdditionalOrderItemProperties(item);
    return item;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) DiscreteOrderItemFeePrice(org.broadleafcommerce.core.order.domain.DiscreteOrderItemFeePrice)

Aggregations

DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)2 DiscreteOrderItemFeePrice (org.broadleafcommerce.core.order.domain.DiscreteOrderItemFeePrice)2 SkuPriceWrapper (org.broadleafcommerce.core.catalog.domain.pricing.SkuPriceWrapper)1 DynamicSkuPrices (org.broadleafcommerce.core.catalog.service.dynamic.DynamicSkuPrices)1