use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class SkuImpl method getPriceData.
@Override
public DynamicSkuPrices getPriceData() {
if (SkuPricingConsiderationContext.hasDynamicPricing()) {
DynamicSkuPrices dynamicPrices = SkuPricingConsiderationContext.getDynamicSkuPrices(this);
return dynamicPrices;
} else {
DynamicSkuPrices dsp = new DynamicSkuPrices();
BroadleafCurrency tmpCurrency;
if (currency != null) {
tmpCurrency = currency;
} else {
tmpCurrency = BroadleafRequestContext.getCurrency();
}
if (retailPrice != null) {
dsp.setRetailPrice(new Money(retailPrice, tmpCurrency));
}
if (salePrice != null) {
dsp.setSalePrice(new Money(salePrice, tmpCurrency));
}
return dsp;
}
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class SkuImpl method getBaseSalePrice.
@Override
public Money getBaseSalePrice() {
Money returnPrice = null;
if (salePrice != null) {
returnPrice = new Money(salePrice, getCurrency());
}
if (returnPrice == null && hasDefaultSku()) {
Sku defaultSku = lookupDefaultSku();
returnPrice = defaultSku.getBaseSalePrice();
}
return returnPrice;
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OrderImpl method createOrRetrieveCopyInstance.
@Override
public <G extends Order> CreateResponse<G> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException {
CreateResponse<G> createResponse = context.createOrRetrieveCopyInstance(this);
if (createResponse.isAlreadyPopulated()) {
return createResponse;
}
Order cloned = createResponse.getClone();
cloned.setCurrency(getCurrency());
cloned.setEmailAddress(emailAddress);
cloned.setLocale(getLocale());
cloned.setName(name);
cloned.setOrderNumber(orderNumber);
cloned.setTotalTax(getTotalTax());
cloned.setSubmitDate(submitDate);
cloned.setCustomer(customer);
cloned.setStatus(getStatus());
cloned.setTotalFulfillmentCharges(getTotalFulfillmentCharges());
cloned.setSubTotal(getSubTotal());
cloned.setTaxOverride(taxOverride == null ? null : taxOverride);
for (OrderItem entry : orderItems) {
OrderItem clonedEntry = entry.createOrRetrieveCopyInstance(context).getClone();
clonedEntry.setOrder(cloned);
cloned.getOrderItems().add(clonedEntry);
}
for (Map.Entry<Offer, OfferInfo> entry : additionalOfferInformation.entrySet()) {
Offer clonedOffer = entry.getKey().createOrRetrieveCopyInstance(context).getClone();
OfferInfo clonedEntry = entry.getValue().createOrRetrieveCopyInstance(context).getClone();
cloned.getAdditionalOfferInformation().put(clonedOffer, clonedEntry);
}
for (Map.Entry<String, OrderAttribute> entry : orderAttributes.entrySet()) {
OrderAttribute clonedAttribute = entry.getValue().createOrRetrieveCopyInstance(context).getClone();
clonedAttribute.setOrder(cloned);
cloned.getOrderAttributes().put(entry.getKey(), clonedAttribute);
}
for (FulfillmentGroup fulfillmentGroup : fulfillmentGroups) {
FulfillmentGroup fg = fulfillmentGroup.createOrRetrieveCopyInstance(context).getClone();
fg.setOrder(cloned);
cloned.getFulfillmentGroups().add(fg);
}
for (OrderPayment orderPayment : payments) {
if (orderPayment.isActive()) {
OrderPayment payment = orderPayment.createOrRetrieveCopyInstance(context).getClone();
payment.setOrder(cloned);
cloned.getPayments().add(payment);
}
}
for (OfferCode entry : addedOfferCodes) {
// We do not want to clone the offer code since that will cascade through offer. We only want to create
// the new relationship between this cloned order and the existing offer code.
cloned.getAddedOfferCodes().add(entry);
}
cloned.setTotal(total == null ? null : new Money(total));
return createResponse;
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OrderImpl method getTotalAfterAppliedPayments.
@Override
public Money getTotalAfterAppliedPayments() {
Money myTotal = getTotal();
if (myTotal == null) {
return null;
}
Money totalPayments = BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, getCurrency());
for (OrderPayment payment : getPayments()) {
// add up all active payments that are not UNCONFIRMED Final Payments
if (payment.isActive() && payment.getAmount() != null && (!payment.isFinalPayment() || payment.isConfirmed())) {
totalPayments = totalPayments.add(payment.getAmount());
}
}
return myTotal.subtract(totalPayments);
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OrderItemImpl method getPriceBeforeAdjustments.
@Override
public Money getPriceBeforeAdjustments(boolean allowSalesPrice, boolean includeChildren) {
boolean retailPriceOverride = false;
for (OrderItemPriceDetail oipd : getOrderItemPriceDetails()) {
if (oipd.getUseSalePrice() == false) {
retailPriceOverride = true;
break;
}
}
Money returnPrice = Money.ZERO;
if (includeChildren) {
for (OrderItem child : getChildOrderItems()) {
Money childPrice = child.getPriceBeforeAdjustments(allowSalesPrice, true);
returnPrice = returnPrice.add(childPrice.multiply(child.getQuantity()).divide(quantity));
}
}
if (allowSalesPrice && !retailPriceOverride) {
return getSalePrice().add(returnPrice);
} else {
return getRetailPrice().add(returnPrice);
}
}
Aggregations