order.tex 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. \section{Order}
  2. \label{sec:order}
  3. \begin{figure}
  4. \centering
  5. \includegraphics[height=1.0\textwidth,angle=90]{images/Order_Overview.eps}
  6. \label{order_overview}
  7. \caption{Order - Class Overview}
  8. \end{figure}
  9. %An Order is a new concept in \salespoint, replacing databaskets from earlier versions.
  10. %An Order provides facilities for individual pricing of products (additional costs or deductions) and state information and manipulation.
  11. An \code{Order} can be considered as a sheet of paper which basically consists of lines, each representing an ordered product.
  12. %(\code{OrderLine}) and lines that are not bound to a concrete product but which cause a charge (\code{ChargeLine}), for example shipping and packaging.
  13. An order can be uniquely identified by an \code{OrderIdentifier}.
  14. Every product of an order is stored in a separate \code{OrderLine}.
  15. An \code{OrderLine} in turn is uniquely identified by an \code{OrderLineIdentifier}.
  16. An \code{OrderLine} contains all information to identify a \code{ProductInstance} (see Section \ref{sec:product}).
  17. A \code{ProductInstance} is identified by a \code{ProductIdentifier}, and an optional set of \code{ProductFeature}s.
  18. \\
  19. A \code{ChargeLine} represents additional costs or discounts and can be applied to an \code{OrderLine} or an \code{Order}.
  20. For example, \code{ChargeLine}s can be used to handle special taxes or handling fees.
  21. A \code{ChargeLine} is uniquely identified by a \code{ChargeLineIdentifier}.
  22. %ChargeLines will be involved in price calculation of \code{Order}s and \code{OrderLine}s.
  23. \\
  24. \code{Orders} are lifecycle-objects.
  25. The lifecycle covers four states which are defined by enumeration type \code{OrderStatus}.
  26. %The lifecycle has restrictions in changing states, which are transposed automatic by the according methods.
  27. %Changing lifecylce states is restricted, which is automatically governed by the according methods, for example \code{cancelOrder()}.
  28. The lifecycle state cannot be arbitrarily changed, but follows a fixed scheme and is represented as field \code{orderStatus} in the class \code{PersistentOrder}.
  29. State transistions are automatically carried out when certain methods are called on an \code{Order} object, for example \code{cancelOrder()}.
  30. %The figure \ref{order_statemachine} shows a state machine which illustrates the lifecycle of \code{Orders}.
  31. \\
  32. As you can see in Figure \ref{order_statemachine}, a PersistentOrder can only be modified in state \code{OPEN}.
  33. \code{PAYED}, \code{CANCELLED} and \code{COMPLETED} \code{Orders} are immutable.
  34. Calling the \code{payOrder()} method changes the state and calls the accountancy to create a \code{ProductPaymentEntry}
  35. Ordered objects will only be removed from inventory when the \code{completeOrder()} method is called.
  36. \code{COMPLETED} is one of the final states and it is not possible to change the state of such orders.
  37. \\
  38. \begin{figure}
  39. \centering
  40. \includegraphics[width=1.0\textwidth]{images/Order_StateMachine.eps}
  41. \label{order_statemachine}
  42. \caption{Order - Lifecycle}
  43. \end{figure}
  44. Completing an order causes product instances to be removed from the inventory.
  45. Because product instances may not be present anymore in the inventory, or their number may not be suffice to fulfill an order, completing an order requires special attention.
  46. To handle these situations, the \code{OrderCompletionResult} interface was introduced.
  47. First of all, three \code{OrderCompletionStatus} are possible:
  48. \begin{itemize}
  49. \item \code{SUCCESSFUL}: The order was completed successfully, and all products were removed from the inventory.
  50. \item \code{SPLIT}: Some products could be found in the inventory and were removed.
  51. \item \code{FAILED}: An error from which recovery is impossible occured.
  52. \end{itemize}
  53. When completing an order results in the \code{SPLIT} status, the original order is splitted: all product that could be removed from the inventory are kept in the original order.
  54. The original order's state is changed to \code{COMPLETED}.
  55. All products which could not be removed from the inventory are transferred to a second order, the split order. The split order is set to \code{PAYED}.
  56. This scheme allows for the Controller to implement whatever logic necessary: placing a product on back order, splitting the order into multiple deliveries, or cancelling the order.
  57. It is paramount to understand, that \code{OrderCompletionResult} does not make a decision, but prepares for every decision, the business logic may come to.
  58. \\
  59. The \code{OrderManager} aggregates \code{Order}s.
  60. The implementations \code{PersistentOrderManager}, \code{PersistentOrder}, and \code{PersistentOrderLine} are used to persist, update, find and remove orders to/from the database.
  61. In \code{Order} aggregated objects, like \code{OrderLine}s and \code{ChargeLine}s will also be persisted, updated or removed with the \code{Order} object.