use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class PromotableOrderImpl method setOrderSubTotalToPriceWithoutAdjustments.
@Override
public void setOrderSubTotalToPriceWithoutAdjustments() {
Money calculatedSubTotal = calculateSubtotalWithoutAdjustments();
order.setSubTotal(calculatedSubTotal);
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OrderItemPriceComparator method compare.
public int compare(PromotableOrderItem c1, PromotableOrderItem c2) {
Money price = c1.getPriceBeforeAdjustments(applyToSalePrice);
Money price2 = c2.getPriceBeforeAdjustments(applyToSalePrice);
// highest amount first
return price2.compareTo(price);
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class SkuPricingConsiderationContext method getDynamicSkuPrices.
public static DynamicSkuPrices getDynamicSkuPrices(Sku sku) {
DynamicSkuPrices prices = null;
if (SkuPricingConsiderationContext.hasDynamicPricing()) {
if (!getThreadCache().containsKey(sku.getId())) {
// We have dynamic pricing, so we will pull the retail price from there
if (!SkuPricingConsiderationContext.isPricingConsiderationActive()) {
SkuPriceWrapper wrapper = new SkuPriceWrapper(sku);
SkuPricingConsiderationContext.startPricingConsideration();
try {
prices = SkuPricingConsiderationContext.getSkuPricingService().getSkuPrices(wrapper, SkuPricingConsiderationContext.getSkuPricingConsiderationContext());
} finally {
SkuPricingConsiderationContext.endPricingConsideration();
}
} else {
try {
prices = new DynamicSkuPrices();
Field retail = getSingleField(sku.getClass(), "retailPrice");
Object retailVal = retail.get(sku);
Money retailPrice = retailVal == null ? null : new Money((BigDecimal) retailVal);
Field sale = getSingleField(sku.getClass(), "salePrice");
Object saleVal = sale.get(sku);
Money salePrice = saleVal == null ? null : new Money((BigDecimal) saleVal);
prices.setRetailPrice(retailPrice);
prices.setSalePrice(salePrice);
} catch (IllegalAccessException e) {
throw ExceptionHelper.refineException(e);
}
}
getThreadCache().put(sku.getId(), prices);
} else {
prices = getThreadCache().get(sku.getId());
}
}
return prices;
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OrderPaymentConfirmationStrategyImpl method constructPendingTransaction.
protected PaymentResponseDTO constructPendingTransaction(PaymentType paymentType, PaymentGatewayType gatewayType, PaymentRequestDTO confirmationRequest) {
PaymentResponseDTO responseDTO = new PaymentResponseDTO(paymentType, gatewayType);
responseDTO.amount(new Money(confirmationRequest.getTransactionTotal())).rawResponse(this.getClass().getName() + ": converting UNCONFIRMED transaction into a PENDING payment").successful(true).paymentTransactionType(PaymentTransactionType.PENDING);
for (String key : confirmationRequest.getAdditionalFields().keySet()) {
responseDTO.responseMap(key, confirmationRequest.getAdditionalFields().get(key).toString());
}
return responseDTO;
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class SkuImpl method getMargin.
@Override
public Money getMargin() {
Money margin = null;
Money price = getPrice();
Money purchaseCost = getCost();
if (price == null && hasDefaultSku()) {
price = lookupDefaultSku().getPrice();
}
if (purchaseCost == null && hasDefaultSku()) {
purchaseCost = lookupDefaultSku().getCost();
}
if (price != null && !price.getAmount().equals(BigDecimal.ZERO)) {
if (purchaseCost != null) {
margin = price.subtract(purchaseCost).divide(price.getAmount());
}
} else {
margin = Money.ZERO;
}
return margin;
}
Aggregations