Script: Class dw.order.ReturnCase

Class ReturnCase

All returns exist in the context of a ReturnCase, each Order can have any number of ReturnCases.
The ReturnCase has ReturnCaseItems, each of which is associated with an OrderItem (an extension to either a ProductLineItem or a ShippingLineItem).
Each ReturnCaseItem defines ReturnCaseItem.getAuthorizedQuantity() representing the maximum quantity expected to be returned. The ReturnCaseItem may be associated with 0..n ReturnItems - ReturnItems are added to the ReturnCaseItem when Returns are created.

Either - a ReturnCase may be used as an RMA, in which case they are created when a customer first shows a wish to return item(s). The customer then includes the RMA number with the returned item(s). The Return created as a result is then associated with the existing ReturnCase.
Or - a ReturnCase is automatically created as part of the return creation, i.e. the customer returns some item(s) leading to a creation of both a Return and an associated ReturnCase.

The scripting api allows access to the ReturnCases, whether the ReturnCase is an RMA or not, and the ReturnCase status. Both the ReturnCaseItems and any Returns associated with the ReturnCase can be accessed.

A ReturnCase has one of these status values:

  • NEW - the ReturnCase has been created and can be edited previous to its authorization
  • CONFIRMED - the ReturnCase is CONFIRMED, can no longer be edited, no Returns have been associated with it. Only a NEW- ReturnCase can be CONFIRMED
  • PARTIAL_RETURNED - the ReturnCase has been associated with at least one Return, but is not yet complete. Only a CONFIRMED- ReturnCase can be set to PARTIAL_RETURNED
  • RETURNED - the ReturnCase has been associated with Returns which match the expected authorized quantity. Only an CONFIRMED- or PARTIAL_RETURNED- return-case can be set to RETURNED
  • CANCELLED - the ReturnCase has been cancelled (only a NEW- or CONFIRMED- ReturnCase can be 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 ReturnCase Status CANCELLED

STATUS_CONFIRMED : String = "CONFIRMED"

constant for ReturnCase Status CONFIRMED

STATUS_NEW : String = "NEW"

constant for ReturnCase Status NEW

STATUS_PARTIAL_RETURNED : String = "PARTIAL_RETURNED"

constant for ReturnCase Status PARTIAL RETURNED

STATUS_RETURNED : String = "RETURNED"

constant for ReturnCase Status RETURNED

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

Access the collection of ReturnCaseItems.

This FilteringCollection can be sorted / filtered using:

returnCaseNumber : String Read Only

The mandatory return case number identifying this document.

returns : Collection Read Only

Return the collection of Returns associated with this ReturnCase.

RMA : boolean Read Only

Return whether this is an RMA. This is specified when calling Order.createReturnCase(String, Boolean).

status : EnumValue Read Only

Gets the return case item status. The status of a ReturnCase is read-only and calculated from the status of the associated ReturnCaseItems.

The possible values are STATUS_NEW,STATUS_CONFIRMED, STATUS_PARTIAL_RETURNED, STATUS_RETURNED, STATUS_CANCELLED.

Constructor Summary

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

Method Summary

confirm() : void

Attempt to confirm the ReturnCase.

createInvoice() : Invoice

Creates a new Invoice based on this ReturnCase.

createInvoice(invoiceNumber : String) : Invoice

Creates a new Invoice based on this ReturnCase.

createItem(orderItemID : String) : ReturnCaseItem

Creates a new item for a given order item.

createReturn(returnNumber : String) : Return

Creates a new Return with the given number and associates it with this ReturnCase.

createReturn() : Return

Creates a new Return with a generated number and associates it with this ReturnCase.

getInvoice() : Invoice

Returns null or the previously created Invoice.

getInvoiceNumber() : String

Returns null or the invoice-number.

getItems() : FilteringCollection

Access the collection of ReturnCaseItems.

getReturnCaseNumber() : String

Returns the mandatory return case number identifying this document.

getReturns() : Collection

Return the collection of Returns associated with this ReturnCase.

getStatus() : EnumValue

Gets the return case item status.

isRMA() : boolean

Return whether this is an RMA.

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

confirm

confirm() : void

Attempt to confirm the ReturnCase.

Without items the return case will be canceled

When confirmed, only the the custom attributes of its return case items can be changed.

Throws:

IllegalStateException - thrown if Status is not STATUS_NEW

createInvoice

createInvoice() : Invoice

Creates a new Invoice based on this ReturnCase. The return-case-number will be used as the invoice-number. The Invoice can then be accessed using getInvoice() or its number using getInvoiceNumber(). The method must not be called more than once for a ReturnCase, nor may 2 Invoices exist with the same invoice-number.

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

Returns:

new invoice


createInvoice

createInvoice(invoiceNumber : String) : Invoice

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

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

Parameters:

invoiceNumber - the invoice-number to be used for the invoice creation

Returns:

new invoice


createItem

createItem(orderItemID : String) : ReturnCaseItem

Creates a new item for a given order item. Note: a ReturnCase may have only one item per order item.

Parameters:

orderItemID - order item id

Returns:

null or item for given order item

Throws:

IllegalArgumentException - thrown if getItem(orderItem) returns non null


createReturn

createReturn(returnNumber : String) : Return

Creates a new Return with the given number and associates it with this ReturnCase.

Parameters:

returnNumber - return number to assign

Returns:

new Return instance


createReturn

createReturn() : Return

Creates a new Return with a generated number and associates it with this ReturnCase.

Returns:

new Return instance


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.

See Also:

createInvoice(String)


getItems

getItems() : FilteringCollection

Access the collection of ReturnCaseItems.

This FilteringCollection can be sorted / filtered using:

Returns:

the items


getReturnCaseNumber

getReturnCaseNumber() : String

Returns the mandatory return case number identifying this document.

Returns:

the return case number


getReturns

getReturns() : Collection

Return the collection of Returns associated with this ReturnCase.

Returns:

the collection of Returns.


getStatus

getStatus() : EnumValue

Gets the return case item status. The status of a ReturnCase is read-only and calculated from the status of the associated ReturnCaseItems.

The possible values are STATUS_NEW,STATUS_CONFIRMED, STATUS_PARTIAL_RETURNED, STATUS_RETURNED, STATUS_CANCELLED.

Returns:

the status


isRMA

isRMA() : boolean

Return whether this is an RMA. This is specified when calling Order.createReturnCase(String, Boolean).

Returns:

whether this is an RMA.