org.broadleafcommerce.core.order.domain
Class OrderImpl

java.lang.Object
  extended by org.broadleafcommerce.core.order.domain.OrderImpl
All Implemented Interfaces:
Serializable, AdminMainEntity, CurrencyCodeIdentifiable, Order

@Entity
public class OrderImpl
extends Object
implements Order, AdminMainEntity, CurrencyCodeIdentifiable

See Also:
Serialized Form

Nested Class Summary
static class OrderImpl.Presentation
           
 
Field Summary
protected  List<OfferCode> addedOfferCodes
           
protected  Map<Offer,OfferInfo> additionalOfferInformation
           
protected  Auditable auditable
           
protected  List<CandidateOrderOffer> candidateOrderOffers
           
protected  BroadleafCurrency currency
           
protected  Customer customer
           
protected  String emailAddress
           
protected  List<FulfillmentGroup> fulfillmentGroups
           
protected  Long id
           
protected  Locale locale
           
protected  String name
           
protected  List<OrderAdjustment> orderAdjustments
           
protected  Map<String,OrderAttribute> orderAttributes
           
protected  List<OrderItem> orderItems
           
protected  List<PaymentInfo> paymentInfos
           
protected  String status
           
protected  Date submitDate
           
protected  BigDecimal subTotal
           
protected  BigDecimal total
           
protected  BigDecimal totalFulfillmentCharges
           
protected  BigDecimal totalTax
           
 
Fields inherited from interface org.broadleafcommerce.common.admin.domain.AdminMainEntity
MAIN_ENTITY_NAME_PROPERTY
 
Constructor Summary
OrderImpl()
           
 
Method Summary
 void addAddedOfferCode(OfferCode offerCode)
          Deprecated. 
 void addOfferCode(OfferCode offerCode)
           
 void addOrderItem(OrderItem orderItem)
          Adds an OrderItem to the list of OrderItems already associated with this Order
 void assignOrderItemsFinalPrice()
          Assigns a final price to all the order items
 Money calculateSubTotal()
          Returns the sum of the item totals.
 boolean containsSku(Sku sku)
          Checks the DiscreteOrderItems in the cart and returns whether or not the given SKU was found.
 boolean equals(Object obj)
           
 boolean finalizeItemPrices()
          Updates the averagePriceField for all order items.
 List<OfferCode> getAddedOfferCodes()
           
 Map<Offer,OfferInfo> getAdditionalOfferInformation()
           
 Auditable getAuditable()
          Gets the auditable associated with this Order instance which tracks changes made to this Order (creation/update)
 List<CandidateOrderOffer> getCandidateOrderOffers()
          Gets the Offers that could potentially apply to this Order.
 Money getCapturedTotal()
          Convenience method for determining how much of the order total has been captured.
 BroadleafCurrency getCurrency()
          The currency that the Order is priced in.
 String getCurrencyCode()
           
 Customer getCustomer()
          Gets the Customer for this Order.
 List<DiscreteOrderItem> getDiscreteOrderItems()
          Returns all of the OrderItems in this Order that are an instanceof DiscreteOrderItem.
 String getEmailAddress()
           
 Money getFulfillmentGroupAdjustmentsValue()
           
 List<FulfillmentGroup> getFulfillmentGroups()
          Gets the FulfillmentGroups associated with this Order.
 String getFulfillmentStatus()
           
 boolean getHasOrderAdjustments()
          Returns true if this item has order adjustments.
 Long getId()
           
 Money getItemAdjustmentsValue()
          Returns the discount value of all the applied item offers for this order.
 int getItemCount()
          This method returns the total number of items in this order.
 Locale getLocale()
           
 String getMainEntityName()
           
 String getName()
          Gets the name of the order, mainly in order to support wishlists.
 List<OrderAdjustment> getOrderAdjustments()
          Returns a unmodifiable List of OrderAdjustment.
 Money getOrderAdjustmentsValue()
          Returns the discount value of all the applied order offers.
 Map<String,OrderAttribute> getOrderAttributes()
          A list of arbitrary attributes added to this order.
 List<OrderItem> getOrderItems()
          Gets all the OrderItems included in this Order
 String getOrderNumber()
          The unique number associated with this Order.
 List<PaymentInfo> getPaymentInfos()
          Gets all the PaymentInfos associated with this Order.
 Money getRemainingTotal()
          Convenience method for determining how much is left on the Order based on the payments that have already been applied.
 OrderStatus getStatus()
          Gets the status of the Order.
 Date getSubmitDate()
          Gets the date that this Order was submitted.
 Money getSubTotal()
          Returns the subtotal price for the order.
 Money getTotal()
          The grand total of this Order which includes all shipping costs and taxes, as well as any adjustments from promotions.
 Money getTotalAdjustmentsValue()
          Returns the total discount value for all applied item and order offers in the order.
 Money getTotalFulfillmentCharges()
          Gets the total fulfillment costs that should be charged for this Order.
 Money getTotalShipping()
           
 Money getTotalTax()
          Gets the total tax for this order, which is the sum of the taxes on all fulfillment groups.
 boolean hasCategoryItem(String categoryName)
          Determines if this Order has an item in the given category.
 int hashCode()
           
 void setAdditionalOfferInformation(Map<Offer,OfferInfo> additionalOfferInformation)
           
 void setAuditable(Auditable auditable)
           
 void setCandidateOrderOffers(List<CandidateOrderOffer> candidateOrderOffers)
          Sets the Offers that could potentially apply to this Order
 void setCurrency(BroadleafCurrency currency)
          Set the currency that the Order is priced in.
 void setCustomer(Customer customer)
          Sets the associated Customer for this Order.
 void setEmailAddress(String emailAddress)
           
 void setFulfillmentGroups(List<FulfillmentGroup> fulfillmentGroups)
           
 void setId(Long id)
           
 void setLocale(Locale locale)
           
 void setName(String name)
          Sets the name of the order in the context of a wishlist.
protected  void setOrderAdjustments(List<OrderAdjustment> orderAdjustments)
           
 void setOrderAttributes(Map<String,OrderAttribute> orderAttributes)
          Sets the map of order attributes.
 void setOrderItems(List<OrderItem> orderItems)
           
 void setOrderNumber(String orderNumber)
          Set the unique order number for this Order
 void setPaymentInfos(List<PaymentInfo> paymentInfos)
          Sets the various payment types associated with this Order
 void setStatus(OrderStatus status)
          Sets the status of the Order
 void setSubmitDate(Date submitDate)
          Set the date that this Order was submitted.
 void setSubTotal(Money subTotal)
          Sets the subtotal price for the order.
 void setTotal(Money orderTotal)
          Used in TotalActivity to set the grand total of this Order.
 void setTotalFulfillmentCharges(Money totalFulfillmentCharges)
          Set the total fulfillment cost of this Order.
 void setTotalShipping(Money totalShipping)
           
 void setTotalTax(Money totalTax)
          Sets the total tax of this order, which is the sum of the taxes on all fulfillment groups.
 boolean updatePrices()
          Updates all of the prices of the OrderItems in this Order
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected Long id

auditable

protected Auditable auditable

name

protected String name

customer

protected Customer customer

status

protected String status

totalTax

protected BigDecimal totalTax

totalFulfillmentCharges

protected BigDecimal totalFulfillmentCharges

subTotal

protected BigDecimal subTotal

total

protected BigDecimal total

submitDate

protected Date submitDate

emailAddress

protected String emailAddress

orderItems

protected List<OrderItem> orderItems

fulfillmentGroups

protected List<FulfillmentGroup> fulfillmentGroups

orderAdjustments

protected List<OrderAdjustment> orderAdjustments

addedOfferCodes

protected List<OfferCode> addedOfferCodes

candidateOrderOffers

protected List<CandidateOrderOffer> candidateOrderOffers

paymentInfos

protected List<PaymentInfo> paymentInfos

additionalOfferInformation

protected Map<Offer,OfferInfo> additionalOfferInformation

orderAttributes

protected Map<String,OrderAttribute> orderAttributes

currency

protected BroadleafCurrency currency

locale

protected Locale locale
Constructor Detail

OrderImpl

public OrderImpl()
Method Detail

getId

public Long getId()
Specified by:
getId in interface Order

setId

public void setId(Long id)
Specified by:
setId in interface Order

getAuditable

public Auditable getAuditable()
Description copied from interface: Order
Gets the auditable associated with this Order instance which tracks changes made to this Order (creation/update)

Specified by:
getAuditable in interface Order
Returns:

setAuditable

public void setAuditable(Auditable auditable)
Specified by:
setAuditable in interface Order

getSubTotal

public Money getSubTotal()
Description copied from interface: Order
Returns the subtotal price for the order. The subtotal price is the price of all order items with item offers applied. The subtotal does not take into account the order promotions, shipping costs or any taxes that apply to this order.

Specified by:
getSubTotal in interface Order
Returns:
the total item price with offers applied

setSubTotal

public void setSubTotal(Money subTotal)
Description copied from interface: Order
Sets the subtotal price for the order. The subtotal price is the price of all order items with item offers applied. The subtotal does not take into account the order offers or any taxes that apply to this order.

Specified by:
setSubTotal in interface Order

calculateSubTotal

public Money calculateSubTotal()
Description copied from interface: Order
Returns the sum of the item totals.

Specified by:
calculateSubTotal in interface Order
Returns:

assignOrderItemsFinalPrice

public void assignOrderItemsFinalPrice()
Description copied from interface: Order
Assigns a final price to all the order items

Specified by:
assignOrderItemsFinalPrice in interface Order

getTotal

public Money getTotal()
Description copied from interface: Order
The grand total of this Order which includes all shipping costs and taxes, as well as any adjustments from promotions.

Specified by:
getTotal in interface Order
Returns:
the grand total price of this Order

setTotal

public void setTotal(Money orderTotal)
Description copied from interface: Order
Used in TotalActivity to set the grand total of this Order. This includes the prices of all of the OrderItems as well as any taxes, fees, shipping and adjustments for all 3.

Specified by:
setTotal in interface Order
Parameters:
orderTotal - the total cost of this Order

getRemainingTotal

public Money getRemainingTotal()
Description copied from interface: Order
Convenience method for determining how much is left on the Order based on the payments that have already been applied. This takes Order.getTotal() and subtracts the sum of all the PaymentInfos associated with this Order. Note that if an order has been fully paid for, this method will return zero.

Specified by:
getRemainingTotal in interface Order
Returns:
Order.getTotal() minus the PaymentInfo.getAmount() for each PaymentInfo on this Order

getCapturedTotal

public Money getCapturedTotal()
Description copied from interface: Order
Convenience method for determining how much of the order total has been captured. This takes the PaymentInfos and checks the PaymentInfoDetailType for captured records.

Specified by:
getCapturedTotal in interface Order
Returns:

getSubmitDate

public Date getSubmitDate()
Description copied from interface: Order
Gets the date that this Order was submitted. Note that if this date is non-null, then the following should also be true:

Specified by:
getSubmitDate in interface Order
Returns:

setSubmitDate

public void setSubmitDate(Date submitDate)
Description copied from interface: Order
Set the date that this Order was submitted. Used in the blCheckoutWorkflow as the last step after everything else has been completed (payments charged, integration systems notified, etc).

Specified by:
setSubmitDate in interface Order
Parameters:
submitDate - the date that this Order was submitted.

getCustomer

public Customer getCustomer()
Description copied from interface: Order
Gets the Customer for this Order.

Specified by:
getCustomer in interface Order
Returns:

setCustomer

public void setCustomer(Customer customer)
Description copied from interface: Order
Sets the associated Customer for this Order.

Specified by:
setCustomer in interface Order

getStatus

public OrderStatus getStatus()
Description copied from interface: Order
Gets the status of the Order.

Specified by:
getStatus in interface Order
Returns:

setStatus

public void setStatus(OrderStatus status)
Description copied from interface: Order
Sets the status of the Order

Specified by:
setStatus in interface Order

getOrderItems

public List<OrderItem> getOrderItems()
Description copied from interface: Order
Gets all the OrderItems included in this Order

Specified by:
getOrderItems in interface Order
Returns:

setOrderItems

public void setOrderItems(List<OrderItem> orderItems)
Specified by:
setOrderItems in interface Order

addOrderItem

public void addOrderItem(OrderItem orderItem)
Description copied from interface: Order
Adds an OrderItem to the list of OrderItems already associated with this Order

Specified by:
addOrderItem in interface Order
Parameters:
orderItem - the OrderItem to add to this Order

getFulfillmentGroups

public List<FulfillmentGroup> getFulfillmentGroups()
Description copied from interface: Order
Gets the FulfillmentGroups associated with this Order. An Order can have many FulfillmentGroups associated with it in order to support multi-address (and multi-type) shipping.

Specified by:
getFulfillmentGroups in interface Order
Returns:
the FulfillmentGroups associated with this Order

setFulfillmentGroups

public void setFulfillmentGroups(List<FulfillmentGroup> fulfillmentGroups)
Specified by:
setFulfillmentGroups in interface Order

setCandidateOrderOffers

public void setCandidateOrderOffers(List<CandidateOrderOffer> candidateOrderOffers)
Description copied from interface: Order
Sets the Offers that could potentially apply to this Order

Specified by:
setCandidateOrderOffers in interface Order

getCandidateOrderOffers

public List<CandidateOrderOffer> getCandidateOrderOffers()
Description copied from interface: Order
Gets the Offers that could potentially apply to this Order. Used in the promotion engine.

Specified by:
getCandidateOrderOffers in interface Order
Returns:

getName

public String getName()
Description copied from interface: Order
Gets the name of the order, mainly in order to support wishlists.

Specified by:
getName in interface Order
Returns:
the name of the order

setName

public void setName(String name)
Description copied from interface: Order
Sets the name of the order in the context of a wishlist. In this fashion, a Customer can have multiple wishlists like "Christmas" or "Gaming Computer" etc.

Specified by:
setName in interface Order

getTotalTax

public Money getTotalTax()
Description copied from interface: Order
Gets the total tax for this order, which is the sum of the taxes on all fulfillment groups. This total is calculated in the TotalActivity stage of the pricing workflow.

Specified by:
getTotalTax in interface Order
Returns:
the total tax for the order

setTotalTax

public void setTotalTax(Money totalTax)
Description copied from interface: Order
Sets the total tax of this order, which is the sum of the taxes on all fulfillment groups. This total should only be set during the TotalActivity stage of the pricing workflow.

Specified by:
setTotalTax in interface Order

getTotalShipping

public Money getTotalShipping()
Specified by:
getTotalShipping in interface Order

setTotalShipping

public void setTotalShipping(Money totalShipping)
Specified by:
setTotalShipping in interface Order

getTotalFulfillmentCharges

public Money getTotalFulfillmentCharges()
Description copied from interface: Order
Gets the total fulfillment costs that should be charged for this Order. This value should be equivalent to the summation of FulfillmentGroup.getTotal() for each FulfillmentGroup associated with this Order

Specified by:
getTotalFulfillmentCharges in interface Order
Returns:
the total fulfillment cost of this Order

setTotalFulfillmentCharges

public void setTotalFulfillmentCharges(Money totalFulfillmentCharges)
Description copied from interface: Order
Set the total fulfillment cost of this Order. Used in the FulfillmentGroupPricingActivity after the cost of each FulfillmentGroup has been calculated.

Specified by:
setTotalFulfillmentCharges in interface Order

getPaymentInfos

public List<PaymentInfo> getPaymentInfos()
Description copied from interface: Order
Gets all the PaymentInfos associated with this Order. An Order can have many PaymentInfos associated with it to support things like paying with multiple cards or perhaps paying some of this Order with a gift card and some with a credit card.

Specified by:
getPaymentInfos in interface Order
Returns:
the PaymentInfos associated with this Order.

setPaymentInfos

public void setPaymentInfos(List<PaymentInfo> paymentInfos)
Description copied from interface: Order
Sets the various payment types associated with this Order

Specified by:
setPaymentInfos in interface Order

hasCategoryItem

public boolean hasCategoryItem(String categoryName)
Description copied from interface: Order
Determines if this Order has an item in the given category.

Specified by:
hasCategoryItem in interface Order
Parameters:
categoryName - the Category.getName() to check
Returns:
true if at least one OrderItem is in the given category, false otherwise.
See Also:
OrderItem#isInCategory(String)}

getOrderAdjustments

public List<OrderAdjustment> getOrderAdjustments()
Description copied from interface: Order
Returns a unmodifiable List of OrderAdjustment. To modify the List of OrderAdjustment, please use the addOrderAdjustments or removeAllOrderAdjustments methods.

Specified by:
getOrderAdjustments in interface Order
Returns:
a unmodifiable List of OrderItemAdjustment

setOrderAdjustments

protected void setOrderAdjustments(List<OrderAdjustment> orderAdjustments)

getDiscreteOrderItems

public List<DiscreteOrderItem> getDiscreteOrderItems()
Description copied from interface: Order
Returns all of the OrderItems in this Order that are an instanceof DiscreteOrderItem. This will also go into each BundleOrderItem (if there are any) and return all of the BundleOrderItem.getDiscreteOrderItems() from each of those as well.

Specified by:
getDiscreteOrderItems in interface Order
Returns:

containsSku

public boolean containsSku(Sku sku)
Description copied from interface: Order
Checks the DiscreteOrderItems in the cart and returns whether or not the given SKU was found. The equality of the SKUs is based on the .equals() method in SkuImpl. This includes checking the DiscreteOrderItems from {link BundleOrderItem.getDiscreteOrderItems()

Specified by:
containsSku in interface Order
Parameters:
sku - The sku to check for
Returns:
whether or not the given SKU exists in the cart

getAddedOfferCodes

public List<OfferCode> getAddedOfferCodes()
Specified by:
getAddedOfferCodes in interface Order

getOrderNumber

public String getOrderNumber()
Description copied from interface: Order
The unique number associated with this Order. Generally preferred to use instead of just using Order.getId() since that exposes unwanted information about your database.

Specified by:
getOrderNumber in interface Order
Returns:
the unique order number for this Order

setOrderNumber

public void setOrderNumber(String orderNumber)
Description copied from interface: Order
Set the unique order number for this Order

Specified by:
setOrderNumber in interface Order

getFulfillmentStatus

public String getFulfillmentStatus()
Specified by:
getFulfillmentStatus in interface Order

getEmailAddress

public String getEmailAddress()
Specified by:
getEmailAddress in interface Order

setEmailAddress

public void setEmailAddress(String emailAddress)
Specified by:
setEmailAddress in interface Order

getAdditionalOfferInformation

public Map<Offer,OfferInfo> getAdditionalOfferInformation()
Specified by:
getAdditionalOfferInformation in interface Order

setAdditionalOfferInformation

public void setAdditionalOfferInformation(Map<Offer,OfferInfo> additionalOfferInformation)
Specified by:
setAdditionalOfferInformation in interface Order

getItemAdjustmentsValue

public Money getItemAdjustmentsValue()
Description copied from interface: Order
Returns the discount value of all the applied item offers for this order. This value is already deducted from the order subTotal.

Specified by:
getItemAdjustmentsValue in interface Order
Returns:
the discount value of all the applied item offers for this order

getFulfillmentGroupAdjustmentsValue

public Money getFulfillmentGroupAdjustmentsValue()
Specified by:
getFulfillmentGroupAdjustmentsValue in interface Order

getOrderAdjustmentsValue

public Money getOrderAdjustmentsValue()
Description copied from interface: Order
Returns the discount value of all the applied order offers. The value returned from this method should be subtracted from the getSubTotal() to get the order price with all item and order offers applied.

Specified by:
getOrderAdjustmentsValue in interface Order
Returns:
the discount value of all applied order offers.

getTotalAdjustmentsValue

public Money getTotalAdjustmentsValue()
Description copied from interface: Order
Returns the total discount value for all applied item and order offers in the order. The return value should not be used with getSubTotal() to calculate the final price, since getSubTotal() already takes into account the applied item offers.

Specified by:
getTotalAdjustmentsValue in interface Order
Returns:
the total discount of all applied item and order offers

updatePrices

public boolean updatePrices()
Description copied from interface: Order
Updates all of the prices of the OrderItems in this Order

Specified by:
updatePrices in interface Order
Returns:
true if at least 1 OrderItem returned true from OrderItem#updatePrices, false otherwise.
See Also:
OrderItem#updatePrices()}

finalizeItemPrices

public boolean finalizeItemPrices()
Description copied from interface: Order
Updates the averagePriceField for all order items.

Specified by:
finalizeItemPrices in interface Order
Returns:

getOrderAttributes

public Map<String,OrderAttribute> getOrderAttributes()
Description copied from interface: Order
A list of arbitrary attributes added to this order.

Specified by:
getOrderAttributes in interface Order

setOrderAttributes

public void setOrderAttributes(Map<String,OrderAttribute> orderAttributes)
Description copied from interface: Order
Sets the map of order attributes.

Specified by:
setOrderAttributes in interface Order

addAddedOfferCode

@Deprecated
public void addAddedOfferCode(OfferCode offerCode)
Deprecated. 

Specified by:
addAddedOfferCode in interface Order

addOfferCode

public void addOfferCode(OfferCode offerCode)
Specified by:
addOfferCode in interface Order

getCurrency

public BroadleafCurrency getCurrency()
Description copied from interface: Order
The currency that the Order is priced in. Note that this is only on Order since all of the other entities that are related (like FulfillmentGroup and OrderItem have a link back to here. This also has the side effect that an Order can only be priced in a single currency.

Specified by:
getCurrency in interface Order
Returns:

setCurrency

public void setCurrency(BroadleafCurrency currency)
Description copied from interface: Order
Set the currency that the Order is priced in.

Specified by:
setCurrency in interface Order

getLocale

public Locale getLocale()
Specified by:
getLocale in interface Order

setLocale

public void setLocale(Locale locale)
Specified by:
setLocale in interface Order

getItemCount

public int getItemCount()
Description copied from interface: Order
This method returns the total number of items in this order. It iterates through all of the discrete order items and sums up the quantity. This method is useful for display to the customer the current number of "physical" items in the cart

Specified by:
getItemCount in interface Order
Returns:
the number of items in the order

getHasOrderAdjustments

public boolean getHasOrderAdjustments()
Description copied from interface: Order
Returns true if this item has order adjustments.

Specified by:
getHasOrderAdjustments in interface Order
Returns:

getMainEntityName

public String getMainEntityName()
Specified by:
getMainEntityName in interface AdminMainEntity

getCurrencyCode

public String getCurrencyCode()
Specified by:
getCurrencyCode in interface CurrencyCodeIdentifiable

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013. All Rights Reserved.