Script: Class dw.order.ShippingOrder

Class ShippingOrder

A shipping order is used to specify items that should be shipped, and is typically exported to, and updated by a back-office warehouse management system.

An Order can have n shipping orders expressing how the order is to be shipped. The creation, export and update of shipping orders is largely handled by custom logic in scripts by implementing ShippingOrderHooks. Use method Order.createShippingOrder() for creation and add items using createShippingOrderItem(OrderItem, Quantity) - each item is related to an order item which in turn represents a product- or shipping- line item in the order.

A shipping order has a status calculated from its item status, one of

  • CONFIRMED - shipping order not yet exported, with 0 items, or all items in status CONFIRMED.
  • WAREHOUSE - shipping order exported, with all items in status WAREHOUSE.
  • SHIPPED - exported shipping order has been updated, with 1-n items in status SHIPPED and 0-n CANCELLED.
  • CANCELLED - exported shipping order has been updated, with all items in status CANCELLED.

The following status transitions are supported. Every status transition is documented by the addition of an order note such as 'Shipping order 123456 status changed to WAREHOUSE.':

FromToWhenUse
CONFIRMEDWAREHOUSEShipping order exportedCall setStatusWarehouse() - note this is the only way to set the items to status WAREHOUSE
WAREHOUSESHIPPEDOne or more items have been SHIPPEDCall ShippingOrderItem.setStatus(String) using ShippingOrderItem.STATUS_SHIPPED
WAREHOUSECANCELLEDAll items have been CANCELLEDCall ShippingOrderItem.setStatus(String) using ShippingOrderItem.STATUS_CANCELLED

Order post-processing APIs (gillian) are now inactive by default and will throw an exception if accessed. Activation needs preliminary approval by Product Management. Please contact support in this case. Existing customers using these APIs are not affected by this change and can use the APIs until further notice.

Constants

ORDERBY_ITEMID : Object

Sorting by item id. Use with method getItems() as an argument to method FilteringCollection.sort(Object).

ORDERBY_ITEMPOSITION : Object

Sorting by the position of the related oder item. Use with method getItems() as an argument to method FilteringCollection.sort(Object).

ORDERBY_UNSORTED : Object

Unsorted , as it is. Use with method getItems() as an argument to method FilteringCollection.sort(Object).

QUALIFIER_PRODUCTITEMS : Object

Selects the product items. Use with method getItems() as an argument to method FilteringCollection.select(Object).

QUALIFIER_SERVICEITEMS : Object

Selects for the service items. Use with method getItems() as an argument to method FilteringCollection.select(Object).

STATUS_CANCELLED : String = "CANCELLED"

Constant for Shipping Order Status CANCELLED

STATUS_CONFIRMED : String = "CONFIRMED"

Constant for Shipping Order Status CONFIRMED

STATUS_SHIPPED : String = "SHIPPED"

Constant for Shipping Order Status SHIPPED

STATUS_WAREHOUSE : String = "WAREHOUSE"

Constant for Shipping Order Status WAREHOUSE

Properties

invoice : Invoice Read Only

Returns null or the previously created Invoice.

invoiceNumber : String Read Only

Returns null or the invoice-number.

items : FilteringCollection Read Only

A filtering collection of the shipping order items belonging to the shipping order.

This FilteringCollection could be sorted / filtered using:

shipDate : Date

Gets the shipping date.

Returns null if this shipping order is not yet shipped.

shippingAddress : OrderAddress

The shipping address (optional, can be null).

Note: the shipping address is not copied into the ShippingOrder but is a link to a OrderAddress held in the Order.

shippingMethod : ShippingMethod Read Only

The shipping method of the shipping order.

Can be null.

shippingOrderNumber : String Read Only

Gets the shipping order number.

status : EnumValue Read Only

Gets the status of this shipping order. The status is read-only and calculated from the item status. See class documentation for more details.
The possible values are STATUS_CONFIRMED, STATUS_WAREHOUSE, STATUS_SHIPPED, STATUS_CANCELLED.

trackingInfos : Collection Read Only

Gets all tracking informations for this shipping order.

Constructor Summary

This class does not have a constructor, so you cannot create it directly.

Method Summary

addTrackingInfo(trackingInfoID : String) : TrackingInfo

Adds a tracking info to this shipping order with the given ID.

createInvoice() : Invoice

Creates a new Invoice based on this ShippingOrder.

createInvoice(invoiceNumber : String) : Invoice

Creates a new Invoice based on this ShippingOrder.

createShippingOrderItem(orderItem : OrderItem, quantity : Quantity) : ShippingOrderItem

Create a ShippingOrderItem in the shipping order with the number shippingOrderNumber.

createShippingOrderItem(orderItem : OrderItem, quantity : Quantity, splitIfPartial : boolean) : ShippingOrderItem

Create a ShippingOrderItem in the shipping order with the number shippingOrderNumber.

getInvoice() : Invoice

Returns null or the previously created Invoice.

getInvoiceNumber() : String

Returns null or the invoice-number.

getItems() : FilteringCollection

A filtering collection of the shipping order items belonging to the shipping order.

getShipDate() : Date

Gets the shipping date.

getShippingAddress() : OrderAddress

Returns the shipping address (optional, can be null).

getShippingMethod() : ShippingMethod

Returns the shipping method of the shipping order.

getShippingOrderNumber() : String

Gets the shipping order number.

getStatus() : EnumValue

Gets the status of this shipping order.

getTrackingInfo(trackingInfoID : String) : TrackingInfo

Gets a tracking info for this shipping order.

getTrackingInfos() : Collection

Gets all tracking informations for this shipping order.

setShipDate(date : Date) : void

Sets the shipping date.

setShippingAddress(address : OrderAddress) : void

Set a shipping address for the shipping order.

setShippingMethodID(shippingMethodID : String) : void

Set the id of shipping method.

setStatusWarehouse() : void

Set a CONFIRMED shipping order (all items in status CONFIRMED) to status WAREHOUSE (all items in status WAREHOUSE).
Note - this method is the only way to transition a shipping order from CONFIRMED to WAREHOUSE.

Methods inherited from class AbstractItemCtnr

getCreatedBy, getCreationDate, getGrandTotal, getItems, getLastModified, getModifiedBy, getOrder, getProductSubtotal, getServiceSubtotal

Methods inherited from class Extensible

describe, getCustom

Methods inherited from class Object

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Method Detail

addTrackingInfo

addTrackingInfo(trackingInfoID : String) : TrackingInfo

Adds a tracking info to this shipping order with the given ID.

Parameters:

trackingInfoID - the tracking info id

Returns:

the new tracking info

See Also:

TrackingInfo

createInvoice

createInvoice() : Invoice

Creates a new Invoice based on this ShippingOrder.

The shipping-order-number will be used as the invoice-number. The Invoice can then be accessed using getInvoice() or getInvoiceNumber() can be used. The method must not be called more than once for a ShippingOrder, nor may 2 Invoices exist with the same invoice-number.

The new Invoice is a debit-invoice with a status Invoice.STATUS_NOT_PAID, and will be passed to the capture payment-hook in a separate database transaction for processing.

Returns:

new invoice


createInvoice

createInvoice(invoiceNumber : String) : Invoice

Creates a new Invoice based on this ShippingOrder.

The invoice-number must be specified as an argument.The Invoice can then be accessed using getInvoice() or getInvoiceNumber() can be used. The method must not be called more than once for a ShippingOrder, nor may 2 Invoices exist with the same invoice-number.

The new Invoice is a debit-invoice with a status Invoice.STATUS_NOT_PAID, and will be passed to the capture payment-hook in a separate database transaction for processing.

Parameters:

invoiceNumber - the invoice-number to use

Returns:

new invoice


createShippingOrderItem

createShippingOrderItem(orderItem : OrderItem, quantity : Quantity) : ShippingOrderItem

Create a ShippingOrderItem in the shipping order with the number shippingOrderNumber.

The quantity of the new item can be optionally specified. A quantity of null indicates the new item should be based on the entire order item and is recommended for ShippingLineItems. If a quantity is specified for a ProductLineItem which is less than ProductLineItem.getQuantity() the ProductLineItem will be split, creating a new ProductLineItem. The new ShippingOrderItem will be associated with the new ProductLineItem, which will receive the specified quantity. See also createShippingOrderItem(OrderItem, Quantity, Boolean).

Parameters:

orderItem - the order item for which the shipping order item is to be created

quantity - the quantity for which the shipping order item will be created

Returns:

the created shipping order item


createShippingOrderItem

createShippingOrderItem(orderItem : OrderItem, quantity : Quantity, splitIfPartial : boolean) : ShippingOrderItem

Create a ShippingOrderItem in the shipping order with the number shippingOrderNumber.

The quantity of the new item can be optionally specified. A quantity of null indicates the new item should be based on the entire order item and is recommended for ShippingLineItems. If the specified quantity is less than ProductLineItem.getQuantity() the ProductLineItem will be split or not depending on splitIfPartial parameter. When split is true, the method is equivalent to createShippingOrderItem(OrderItem, Quantity).

Parameters:

orderItem - the order item for which the shipping order item is to be created

quantity - the quantity for which the shipping order item will be created, not null

splitIfPartial - the flag whether ProductLineItem should be split when requested quantity is less than ProductLineItem's quantity

Returns:

the created shipping order item


getInvoice

getInvoice() : Invoice

Returns null or the previously created Invoice.

Returns:

null or the previously created invoice.

See Also:

createInvoice(String)


getInvoiceNumber

getInvoiceNumber() : String

Returns null or the invoice-number.

Returns:

null or the previously created invoice number.

See Also:

createInvoice(String)


getItems

getItems() : FilteringCollection

A filtering collection of the shipping order items belonging to the shipping order.

This FilteringCollection could be sorted / filtered using:

Returns:

the filtering collection of the shipping items.

See Also:

createShippingOrderItem(OrderItem, Quantity)

ShippingOrderItem


getShipDate

getShipDate() : Date

Gets the shipping date.

Returns null if this shipping order is not yet shipped.

Returns:

the shipping date or null


getShippingAddress

getShippingAddress() : OrderAddress

Returns the shipping address (optional, can be null).

Note: the shipping address is not copied into the ShippingOrder but is a link to a OrderAddress held in the Order.

Returns:

the shipping address or null


getShippingMethod

getShippingMethod() : ShippingMethod

Returns the shipping method of the shipping order.

Can be null.

Returns:

the shipping method or null


getShippingOrderNumber

getShippingOrderNumber() : String

Gets the shipping order number.

Returns:

the shipping order number


getStatus

getStatus() : EnumValue

Gets the status of this shipping order. The status is read-only and calculated from the item status. See class documentation for more details.
The possible values are STATUS_CONFIRMED, STATUS_WAREHOUSE, STATUS_SHIPPED, STATUS_CANCELLED.

Returns:

the status


getTrackingInfo

getTrackingInfo(trackingInfoID : String) : TrackingInfo

Gets a tracking info for this shipping order.

Parameters:

trackingInfoID - the tracking info id

Returns:

the tracking info or null

See Also:

TrackingInfo


getTrackingInfos

getTrackingInfos() : Collection

Gets all tracking informations for this shipping order.

Returns:

all tracking informations for this shipping order

See Also:

TrackingInfo


setShipDate

setShipDate(date : Date) : void

Sets the shipping date.

Parameters:

date - the ship date


setShippingAddress

setShippingAddress(address : OrderAddress) : void

Set a shipping address for the shipping order.

Parameters:

address - the shipping address

See Also:

getShippingAddress()


setShippingMethodID

setShippingMethodID(shippingMethodID : String) : void

Set the id of shipping method.

Parameters:

shippingMethodID - the id of the shipping method

See Also:

ShippingMethod.getID()


setStatusWarehouse

setStatusWarehouse() : void

Set a CONFIRMED shipping order (all items in status CONFIRMED) to status WAREHOUSE (all items in status WAREHOUSE).
Note - this method is the only way to transition a shipping order from CONFIRMED to WAREHOUSE.

Throws:

IllegalArgumentException - if the shipping order is in a status other than CONFIRMED.