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;
}
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;
}
Aggregations