Popular Posts

Commands in the Order Flow



The Order Management subsystem includes all logic and data relevant to placing, processing, and managing orders. 

  • OrderCreate: The order will be created even though there is no orderitems in the cart.
  • OrderItemAdd: When the customer selects the item and click on the add to the cart, then the OrderItemAddCmd will be called. The order state will be pending (P).
  • OrderItemUpdate: This command will be called when the quantity of the item is updated in the shopping cart page. The order state will be pending (P).
  • OrderCalculate: This command will be called when the customer adds the orderitems in the cart. The order state will be pending (P). OrderCalculate does only subset of what "OrderPrepare" task does. OrderCalculate with calculationUsageId set to -1, invokes the promotion engine for just price discounts
  • OrderItemMove: This command merges the current pending order to the previous order when the customer places the order by signing on to the store.
  • OrderPrepare: It basically calculates determines the discount, prices, shipping charges and taxes for the order. Lock the order to indicate that it is ready for the OrderProcess command. The lock can be reset either by expiry, by changing the Order (for example, by using the OrderItemUpdate command), or explicitly by using the OrderUnlock command. The expiry period for a lock is stored in the QUOTEGOODFOR column of the STORE table.
  • OrderProcess: Submits the order. Here, the order can be blocked for several reasons.  This may be due to manual verification of the customer. It submits an order for processing. The order must have been locked by the OrderPrepare command. The order payment has not been captured completely. If the full payment has been captured then the state of the order is complete (C) i.e. payment authorization is complete. When the partial payment has been captured the order state will be (M) i.e. part of the amount has been approved.
  • OrderCancel: The order can be cancelled through Customer Sales Representatives, before the order is released to Fulfillment. OrderCancel can cancel orders with an order status of P, X, W, E, A, B, C, M and OrderItem not in R, S, F, and G. Here the order state will be cancelled (X).
  • OrderEdit: This will be called, when the CSR is working with the order. The editor id will be assigned to the order. The order state will be CSR Edit (E). The order can be edit before the releasing the order.

Commands explained in detail



OrderItemAddCmd

This command adds items or products to the shopping cart.

Flow

ResolveSkuCmdImpl --> OrderCreateCmd --> ResolveOrderItemPriceCmd --> UpdateShippingAddressCmd --> ValidateTradingPaymentCmd --> DoInventoryActionCmd(CheckInventory) --> UpdateShipInfoCmdImpl --> RaiseOrderEventCmdImpl --> OrderCalculateCmd --> ExtendedOrderItemProcessCmd

Steps explained in sequence
  • Check if the order is locked by the current CSR.
  • If the order is not locked and called by a CSR, or if it is locked by another CSR, an exception is thrown.
  • Calls ResolveSkuCmd to resolve the SKU and check if the catalog entry is buyable in this store. This command first determines the type of CatalogEntry that is provided as input to the command. If it is a Package, then the PackageResolveSku command is called. If it is a Product, then first the command determines the distinct Attributes that are needed to resolve the Product into an orderable Item.
  • Calls ResolveOrdersCmd to resolve order IDs.
  • If no order is resolved, then OrderCreateCmd is called to create an order.
  • Creates an order item with the information if passed in like catEntryId/partNumber, quantity, correlationGroup etc.
  • Updates comments, description, and shipAsComplete for the order if any
For all the new items that got created:
  • Calls ResolveOrderItemPriceCmd to calculate the best price and update order total. This command resolves price for a group of order items from one order. It calls GetContractUnitPriceCmd/GetContractSpecialPriceCmd task command to calculate the price. If GetContractUnitPriceCmd/GetContractSpecialPriceCmd is not available, it calls GetBaseUnitPriceCmd/GetBaseSpecialPriceCmd.
  • If doPrice is passed to ResolveOrderItemPriceCmd, then the OrderItems can skip pricing again
  • Calls UpdateShippingAddressCmd to update shipping address
  • Updates shipping mode
  • Calls ValidateTradingPaymentCmd to validate that the payment method is compatible with the trading agreement
  • If doInventory = Y, then it calls DoInventoryActionCmd to update the fulfillment centers and check for available inventory
  • Calls UpdateShipInfoCmd to update the shipping instructions, shipping account number and shipping charge type
  • Calls RaiseOrderEventCmd to raise ORDERITEM_CREATION_EVENT or ORDERITEM_UPDATE_EVENT
  • If the flag calculateOrder is set, then it  calls OrderCalculateCmd to do calculations that are based on the calUsageIds passed in
  • Calls ExtendOrderItemProcessCmd to execute any customization logic

OrderItemUpdateCmd

This command updates order items in an existing Order.
 
Flow

DoInventoryActionCmd(Reserve Inventory) --> AddOrderItemComponentsCmd --> ResolveOrderItemPriceCmd --> UpdateShippingAddressCmd --> ValidateTradingPaymentCmd --> DoInventoryActionCmd(Check Inventory) -->  updateShipInfoCmdImpl  --> RaiseOrderEventCmdImpl --> OrderCalculateCmd --> ExtendedOrderItemProcessCmd
Steps explained in sequence
  • Check if the order is locked by the current CSR.
  • If the order is not locked and called by a CSR, or if it is locked by another CSR, an exception is thrown.
If orderItemId is passed in:
  • Updates the existing order item with any of the following information that is passed in: requestedShipDate, isExpedited, tieCode, quantity, correlationGroup, itemSpecId, comments, description, field1, field2
  • Records the new order item as touched
  • If quantity is 0, it deletes the order item and calls DoInventoryActionCmd to reverse the inventory update.
In ATP inventory systems it calls the command ReserveInventoryCmd. In Non-ATP inventory systems calls the UpdateInventoryCmd.
ReserveInventoryCmd: This command gets the quantity available for the requested item, in store, and fulfillment center. Then, it checks whether the quantity available is greater or equal to the quantity requested. If it is successful, then it obtains the ITEMFFMCTR row and increments the itemffmctr.qtyreserved with the requested quantity, and insert a new row into the INVRESERVE table.
UpdateInventoryCmd: This command updates inventory for items.
  • If the order item is a kit or package, then it calls AddOrderItemComponentsCmd to update the component lists
If orderId is passed in:
  • Updates order level shipping information for all order items in the order.
  • Updates the requestedShipDate if passed in for the order item
  • Records the new order item as touched
  • When both shipModeId and addressId are passed, the shipModeId is updated only if the passed addressId is identical to the existing addessId of the order item. If the addressId values are not identical, the shipModeId is not updated.
  • When only one of either shipModeId or addressId is passed, either shipModeId or addressId is updated accordingly.
  • Update comments, description and shipAsComplete for order
For all the updated items:
  • Calls ResolveOrderItemPriceCmd to calculate the best price and update order total. This command resolves price for a group of order items from one order. It calls GetContractUnitPriceCmd/GetContractSpecialPriceCmd task command to calculate the price. If GetContractUnitPriceCmd/GetContractSpecialPriceCmd is not available, it calls GetBaseUnitPriceCmd/GetBaseSpecialPriceCmd.
  • If doPrice is passed to ResolveOrderItemPriceCmd, then the OrderItems can skip pricing again
  • Calls UpdateShippingAddressCmd to update shipping address
  • Updates shipping mode
  • Calls ValidateTradingPaymentCmd to validate the payment method is compatible with the trading agreement
  • If doInventory = Y, calls DoInventoryActionCmd to update the fulfillment centers and check for available inventory
  • Calls UpdateShipInfoCmd to update the shipping instructions, shipping account number and shipping charge type
  • Calls RaiseOrderEventCmd to raise ORDERITEM_CREATION_EVENT or ORDERITEM_UPDATE_EVENT
  • If the flag calculateOrder is set, then it  calls OrderCalculateCmd to do calculations that are based on the calUsageIds passed in
  • Call ExtendOrderItemProcessCmd to execute any customization logic

OrderItemDeleteCmd

This command deletes the order items based on orderItemId or catEntryId specified

Flow
DoInventoryActionCmd(ReserveInventory) --> PrepareShipInfoCmd --> ReolveOrderItemPriceCmd --> OrderCalculateCmd
Steps explained in sequence
  • Checks if the order is locked by the current CSR
  • If the order is not locked and called by a CSR, or if it is locked by another CSR, an exception is thrown
  • Calls DoInventoryActionCmd to reverse the update to the inventory for the deleted order item.
  • Deletes the components of the order item if it is a kit or a package
  • Deletes the order item
  • Calls PrepareShipInfoCmd to delete the orphaned shipping information records. It performs a verification between the SHIPINFO table and the ORDERITEMS table and checks for orphaned SHIPINFO records. Such records will be removed. An orphaned record is a SHIPINFO record which does not have a matching ORDERITEMS record.
  • Calls ResolveOrderItemPriceCmd to calculate the best price and update the order total
  • Calls EventService to raise ORDERITEM_UPDATE_EVENT
  • If the flag calculateOrder is set, then it  calls OrderCalculateCmd to do calculations that are based on the calUsageIds passed in

OrderPrepareCmd

This command prepares an order by determining prices, discounts, shipping charges, shipping adjustment, and taxes for an order. If an order reference number is not specified, all current pending orders will be prepared for the current customer at the given store.

Flow

ValidateShippingAdjustmentCmd --> PrepareOrderCmd
Steps explained in sequence
  • Checks if the order is locked by the current CSR.
  • If the order is not locked and called by a CSR, or if it is locked by another CSR, an exception is thrown
  • Calls ValidateShippingAdjustmentCmd to validate that the order has not changed since a shipping adjustment was added
  • Calls PrepareOrderCmd to do pricing, inventory and calculation on the order. In general, this command prepares an order by determining prices, discounts, shipping charges, and taxes for an order.
    • Deletes generated order items (ORDERITEMS.PREPAREFLAGS = 1, indicates generated orderitems).
    • Checks that all order items in the order are buyable (CATENTRY.BUYABLE=1).
    • Calls DoInventoryActionCmd to check the availability of the products with action CHECK_INVENTORY (CheckInventoryCmd)
    • Calls UpdateShippingAddressCmd to find the appropriate shipping address for all the order items and update them for each order item. If the order item is a dynamic kit, then it calls ValidateDynamicKitConfigurationCmd to do validation
    • Calls ResolveOrderItemPriceCmd to calculate the best price and update order total. Obtains latest unit price for each order item, except those with manually overridden prices or are quotations. (ORDERITEMS.PREPAREFLAGS = ).
    • Re-calculates the amounts for the order.
    • Locks the order to indicate that it is ready for the OrderProcess command. The lock can be reset either by expiry, by changing the Order (for example, by using the OrderItemUpdate command), or explicitly by using the OrderUnlock command. The expiry period for a lock is stored in the STORE.QUOTEGOODFOR.

OrderProcessCmd

This command submits an order for processing. The order must be locked by the Order Prepare command before calling this command.
 
Flow

OrderCommentRecordContrlCmd --> PIAddCmd -->  ValidatePaymentMethodCmd --> ProcessOrderCmd --> RaiseOrdereventCmd
OR
OrderCommentRecordContrlCmd -->  PIAddCmd --> ValidatePaymentMethodCmd --> BusinessFlowUrlEventCmd --> ProcessOrderCmd --> RaiseOrdereventCmd

Steps explained in sequence

  • Calls OrderCommentRecordContrlCmd to process any order comments from the CSR.
    If the flag updateChannelId is set, then it updates the order channel Id
·         Calls PIAddCmd to add payment instructions if the remaining amount is greater than zero and if isPIAddNeeded = Y
·         Calls ValidatePaymentMethodCmd to validate any existing PIs for the current order
If Unified Business Flow is enabled:
  • Calls BusinessFlowUrlEventCmd (UBF command) to process the order in Unified Business Flow:
    • Initializes BusinessFlowEvent
    • In BusinessFlowEventListener
      • Executes OrderProcessPreApprovalCmd, which invokes PreProcessOrderCmd
      • Executes OrderProcessCheckApprovalCmd to check whether approval is required
      • Executes OrderProcessPostApprovalCmd, which invokes ProcessOrderCmd
Otherwise:
  • Calls ProcessOrderCmd directly to process order without Unified Business Flow
    • If either UBF is not enabled or it is enabled and Approval is required, calls PreProcessOrderCmd.
    • If UBF is not enabled, calls mergeShopperPayInfo(OrderAccessBean) to merge the payment info for this order.
    • Calls handleOrderFraud(OrderAccessBean) to detect any fraud order.
    • Configures the order notification and calls checkOrderAndItemTotals() to perform validation on order totals and order Item totals.
    • Calls DoInventoryActionCmd with action ALLOCATE_INVENTORY to update inventory.
    • Calls getInitialAmount() to retrieve the initial payment amount used for Payment actions during EDP PrimePayment. If it's bigger than order total, throw exception.
    • Calls UpdateSpendingLimitCmd to check the trading agreement spending limit and validate the PO number PrimePaymentCmd is invoked to process the payment information associated with the order.
    • Calls paymentAndReleaseRelationshipEnabled() to get to know whether the feature of "build relationship between payment and release" is enabled. If so, put the order items which would be processed by payment into the request properties.
    • Calls RaiseOrderSubmitEventCmd to raise the order submit event.
    • Updates the status of the order based on the inventory status.
    • Calls CalculationHelper to finalize calculation usages.
    • Updates the status of the order and the order items accordingly.
    • Configures the notification attributes so that an email notification can be sent.
    • If OrdersMgpPersistListener is enabled, calls PersistOrdersWithMemberGroupIdsForCurrentUserCmd to persist the order id with the member group id.
    • Calls ExtOrderProcessCmd to execute customization logic.
    • Validate the order inventory status. If backorder is not allowed and one of the items in the order is backordered, throw exception.
    • Calls TransferOrderCmd to transfer the order to external system if needed.
    • Calls OrderMessagingCmd to generate the outbound Order Create Message.
    • Calls NotificationHelper to notify shopper that an order is received.
  • Calls RaiseOrderEventCmd to raise ORDER_SUBMISSION_EVENT

5 comments:

  1. Very Nice blog. Can you please provide some more details for Cmds- RaiseOrderSubmitEventCmd ,ExtOrderProcessCmd ,RaiseOrderEventCmd ,OrderMessagingCmd.

    ReplyDelete
  2. Hey Uma, Very informative and put it in a better way than what ibm infocenter provides :-)

    ReplyDelete
  3. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Best quoting software

    ReplyDelete
  4. Thank you so much to share the valuable content with us. Keep us updating with more interesting and amazing articles. Also, check out Business Events Places in Miami.

    ReplyDelete