Package org.salespointframework.order
Class Order
- java.lang.Object
-
- org.salespointframework.core.AbstractEntity<OrderIdentifier>
-
- org.salespointframework.order.Order
-
- All Implemented Interfaces:
org.springframework.data.domain.Persistable<OrderIdentifier>
@Entity public class Order extends AbstractEntity<OrderIdentifier>
- Author:
- Thomas Dedek, Paul Henke, Oliver Gierke
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOrder.OrderCancelledstatic classOrder.OrderCompletedstatic classOrder.OrderPaid
-
Constructor Summary
Constructors Modifier Constructor Description protectedOrder()Order(UserAccount userAccount)Creates a new OrderOrder(UserAccount userAccount, PaymentMethod paymentMethod)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ChargeLineadd(ChargeLine chargeLine)Deprecated.since 7.1, useaddChargeLine(MonetaryAmount, String)insteadOrderLineadd(OrderLine orderLine)Deprecated.since 7.1, useaddOrderLine(Product, Quantity)instead.ChargeLineaddChargeLine(javax.money.MonetaryAmount price, String description)Adds aChargeLinewith the given price and description to theOrder.ChargeLine.AttachedChargeLineaddChargeLine(javax.money.MonetaryAmount price, String description, int index)Adds anChargeLine.AttachedChargeLinewith the given price and description to theOrderLinewith the given index.ChargeLine.AttachedChargeLineaddChargeLine(javax.money.MonetaryAmount price, String description, OrderLine orderLine)Adds anChargeLine.AttachedChargeLinewith the given price and description to the givenOrderLine.OrderLineaddOrderLine(Product product, Quantity quantity)Totalable<ChargeLine>getAllChargeLines()Returns allChargeLineinstances, i.e. both standard ones andChargeLine.AttachedChargeLines.Totalable<ChargeLine>getChargeLines()Returns allChargeLineinstances registered for the currentOrder.Totalable<ChargeLine.AttachedChargeLine>getChargeLines(int index)Returns allChargeLine.AttachedChargeLines for theOrderLinewith the given index.Totalable<ChargeLine.AttachedChargeLine>getChargeLines(OrderLine orderLine)Returns allChargeLine.AttachedChargeLines for the givenOrderLine.javax.money.MonetaryAmountgetChargeLinesPrice()Deprecated.since 7.1, prefergetChargeLines(),getAllChargeLines()and callPricedTotalable#getTotal()on the result for fine grained control over whichChargeLines to calculate the total for.LocalDateTimegetDateCreated()OrderIdentifiergetId()javax.money.MonetaryAmountgetOrderedLinesPrice()Deprecated.since 7.1, usegetOrderLines()and callTotalable.getTotal()on the result.Totalable<OrderLine>getOrderLines()Totalable<OrderLine>getOrderLines(Product product)OrderStatusgetOrderStatus()PaymentMethodgetPaymentMethod()javax.money.MonetaryAmountgetTotal()Returns the total price of theOrder.javax.money.MonetaryAmountgetTotalPrice()Deprecated.since 7.1, usegetTotal()instead.UserAccountgetUserAccount()booleanisCanceled()Convenience method for checking if an order has the status CANCELLEDbooleanisCompleted()Convenience method for checking if an order has the status COMPLETEDbooleanisOpen()Convenience method for checking if an order has the status OPENbooleanisPaid()Convenience method for checking if an order has the status PAIDvoidremove(ChargeLine chargeLine)voidremove(ChargeLine.AttachedChargeLine chargeLine)Removes the givenChargeLine.AttachedChargeLinefrom theOrder.voidremove(OrderLine orderLine)Removes the givenOrderLineas well as allChargeLine.AttachedChargeLineassociated with it.voidremoveChargeLinesFor(OrderLine orderLine)Removes allChargeLine.AttachedChargeLines attached to the givenOrderLine.voidsetPaymentMethod(PaymentMethod paymentMethod)StringtoString()-
Methods inherited from class org.salespointframework.core.AbstractEntity
equals, hashCode, isNew
-
-
-
-
Constructor Detail
-
Order
public Order(UserAccount userAccount)
Creates a new Order- Parameters:
userAccount- TheUserAccountconnected to this order, must not be null.
-
Order
public Order(UserAccount userAccount, PaymentMethod paymentMethod)
- Parameters:
userAccount- TheUserAccountconnected to this order, must not be null.paymentMethod- ThePaymentMethodconnected to this order, must not be null.
-
Order
protected Order()
-
-
Method Detail
-
getId
public OrderIdentifier getId()
-
getOrderLines
public Totalable<OrderLine> getOrderLines(Product product)
- Parameters:
product- must not be null.- Returns:
- Since:
- 7.1
-
getChargeLines
public Totalable<ChargeLine> getChargeLines()
Returns allChargeLineinstances registered for the currentOrder.- Returns:
-
getAllChargeLines
public Totalable<ChargeLine> getAllChargeLines()
Returns allChargeLineinstances, i.e. both standard ones andChargeLine.AttachedChargeLines.- Returns:
-
getChargeLines
public Totalable<ChargeLine.AttachedChargeLine> getChargeLines(int index)
Returns allChargeLine.AttachedChargeLines for theOrderLinewith the given index.- Parameters:
index- must be in the range ofOrderLines.- Returns:
- Since:
- 7.1
-
getChargeLines
public Totalable<ChargeLine.AttachedChargeLine> getChargeLines(OrderLine orderLine)
Returns allChargeLine.AttachedChargeLines for the givenOrderLine.- Parameters:
orderLine- must not be null.- Returns:
- Since:
- 7.1
-
getTotal
public javax.money.MonetaryAmount getTotal()
Returns the total price of theOrder.- Returns:
- Since:
- 7.1
-
getTotalPrice
@Deprecated public javax.money.MonetaryAmount getTotalPrice()
Deprecated.since 7.1, usegetTotal()instead.Returns the total price of theOrder.- Returns:
-
getOrderedLinesPrice
@Deprecated public javax.money.MonetaryAmount getOrderedLinesPrice()
Deprecated.since 7.1, usegetOrderLines()and callTotalable.getTotal()on the result.Returns the total of allOrderLines.- Returns:
-
getChargeLinesPrice
@Deprecated public javax.money.MonetaryAmount getChargeLinesPrice()
Deprecated.since 7.1, prefergetChargeLines(),getAllChargeLines()and callPricedTotalable#getTotal()on the result for fine grained control over whichChargeLines to calculate the total for.Returns the total of all charge lines registered with the order and order lines.- Returns:
-
add
@Deprecated public OrderLine add(OrderLine orderLine)
Deprecated.since 7.1, useaddOrderLine(Product, Quantity)instead.- Parameters:
orderLine- theOrderLineto be added.- Returns:
- the
OrderLineadded. - Throws:
IllegalArgumentException- if orderLine is null.
-
addOrderLine
public OrderLine addOrderLine(Product product, Quantity quantity)
- Parameters:
product- must not be null.quantity- must not be null.- Returns:
- the
OrderLineadded. - Since:
- 7.1
-
remove
public void remove(OrderLine orderLine)
Removes the givenOrderLineas well as allChargeLine.AttachedChargeLineassociated with it.- Parameters:
orderLine- must not be null.
-
add
@Deprecated public ChargeLine add(ChargeLine chargeLine)
Deprecated.since 7.1, useaddChargeLine(MonetaryAmount, String)insteadAdds a charge line to theOrder.- Parameters:
chargeLine-
-
addChargeLine
public ChargeLine addChargeLine(javax.money.MonetaryAmount price, String description)
Adds aChargeLinewith the given price and description to theOrder.- Parameters:
price- must not be null.description- must not be null.- Returns:
- the
ChargeLinecreated. - Since:
- 7.1
-
addChargeLine
public ChargeLine.AttachedChargeLine addChargeLine(javax.money.MonetaryAmount price, String description, int index)
Adds anChargeLine.AttachedChargeLinewith the given price and description to theOrderLinewith the given index.- Parameters:
price- must not be null.description- must not be null.index- must be within the range ofOrderLines already registered.- Returns:
- the
ChargeLine.AttachedChargeLinecreated. - Since:
- 7.1
-
addChargeLine
public ChargeLine.AttachedChargeLine addChargeLine(javax.money.MonetaryAmount price, String description, OrderLine orderLine)
Adds anChargeLine.AttachedChargeLinewith the given price and description to the givenOrderLine.- Parameters:
price- must not be null.description- must not be null.orderLine- must not be null.- Returns:
- the
ChargeLine.AttachedChargeLinecreated. - Since:
- 7.1
-
remove
public void remove(ChargeLine chargeLine)
-
remove
public void remove(ChargeLine.AttachedChargeLine chargeLine)
Removes the givenChargeLine.AttachedChargeLinefrom theOrder.- Parameters:
chargeLine- must not be null.- Since:
- 7.1
-
removeChargeLinesFor
public void removeChargeLinesFor(OrderLine orderLine)
Removes allChargeLine.AttachedChargeLines attached to the givenOrderLine.- Parameters:
orderLine- must not be null.- Since:
- 7.1
-
isPaid
public boolean isPaid()
Convenience method for checking if an order has the status PAID- Returns:
- true if OrderStatus is PAID, otherwise false
-
isCanceled
public boolean isCanceled()
Convenience method for checking if an order has the status CANCELLED- Returns:
- true if OrderStatus is CANCELLED, otherwise false
-
isCompleted
public boolean isCompleted()
Convenience method for checking if an order has the status COMPLETED- Returns:
- true if OrderStatus is COMPLETED, otherwise false
-
isOpen
public boolean isOpen()
Convenience method for checking if an order has the status OPEN- Returns:
- true if OrderStatus is OPEN, otherwise false
-
setPaymentMethod
public void setPaymentMethod(PaymentMethod paymentMethod)
-
getPaymentMethod
public PaymentMethod getPaymentMethod()
-
getUserAccount
public UserAccount getUserAccount()
-
getDateCreated
public LocalDateTime getDateCreated()
-
getOrderStatus
public OrderStatus getOrderStatus()
-
-