Class Invoice

The Invoice can be a debit or credit invoice, and is created from custom scripts using one of the methods ShippingOrder.createInvoice(String), Appeasement.createInvoice(String), ReturnCase.createInvoice(String) or Return.createInvoice(String).

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.

ConstantDescription
ORDERBY_CREATION_DATE: ObjectSorting by creation date.
ORDERBY_ITEMID: ObjectSorting by item id.
ORDERBY_ITEMPOSITION: ObjectSorting by the position of the related oder item.
ORDERBY_REVERSE: ObjectReverse orders.
ORDERBY_UNSORTED: ObjectUnsorted , as it is.
QUALIFIER_CAPTURE: ObjectSelects the capture transactions.
QUALIFIER_PRODUCTITEMS: ObjectSelects the product items.
QUALIFIER_REFUND: ObjectSelects the refund transactions.
QUALIFIER_SERVICEITEMS: ObjectSelects for the service items.
STATUS_FAILED: String = "FAILED"Constant for Invoice Status Failed. The invoice handling failed.
STATUS_MANUAL: String = "MANUAL"Constant for Invoice Status Manual. The invoice is not paid but will not be handled automatically. A manual invoice handling (capture or refund) is necessary.
STATUS_NOT_PAID: String = "NOT_PAID"Constant for Invoice Status Not Paid. The invoice is not paid and will be handled automatically.
STATUS_PAID: String = "PAID"Constant for Invoice Status Paid. The invoice was successfully paid.
TYPE_APPEASEMENT: String = "APPEASEMENT"Constant for Invoice Type Appeasement. The invoice was created for an appeasement. The invoice amount needs to be refunded.
TYPE_RETURN: String = "RETURN"Constant for Invoice Type Return. The invoice was created for a return. The invoice amount needs to be refunded.
TYPE_RETURN_CASE: String = "RETURN_CASE"Constant for Invoice Type Return Case. The invoice was created for a return case. The invoice amount needs to be refunded.
TYPE_SHIPPING: String = "SHIPPING"Constant for Invoice Type Shipping. The invoice was created for a shipping order. The invoice amount needs to be captured.
PropertyDescription
capturedAmount: Money (read-only)Returns the sum of the captured amounts.
invoiceNumber: String (read-only)Returns the invoice number.
items: FilteringCollection (read-only)Access the collection of InvoiceItems.
paymentTransactions: FilteringCollection (read-only)Returns the payment transactions belonging to this Invoice.
refundedAmount: Money (read-only)Returns the sum of the refunded amounts.
status: EnumValueReturns the invoice status. The possible values are STATUS_NOT_PAID, STATUS_MANUAL, STATUS_PAID, STATUS_FAILED.
type: EnumValue (read-only)Returns the invoice type. The possible values are TYPE_SHIPPING, TYPE_RETURN, TYPE_RETURN_CASE, TYPE_APPEASEMENT.

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

MethodDescription
account()

The invoice will be accounted.

addCaptureTransaction(OrderPaymentInstrument, Money)Calling this method registers an amount captured for a given order payment instrument.
addRefundTransaction(OrderPaymentInstrument, Money)Calling this method registers an amount refunded for a given order payment instrument.
getCapturedAmount()Returns the sum of the captured amounts.
getInvoiceNumber()Returns the invoice number.
getItems()Access the collection of InvoiceItems.
getPaymentTransactions()Returns the payment transactions belonging to this Invoice.
getRefundedAmount()Returns the sum of the refunded amounts.
getStatus()Returns the invoice status. The possible values are STATUS_NOT_PAID, STATUS_MANUAL, STATUS_PAID, STATUS_FAILED.
getType()Returns the invoice type. The possible values are TYPE_SHIPPING, TYPE_RETURN, TYPE_RETURN_CASE, TYPE_APPEASEMENT.
setStatus(String)Sets the invoice status. The possible values are STATUS_NOT_PAID, STATUS_MANUAL, STATUS_PAID, STATUS_FAILED.

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

describe, getCustom

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

ORDERBY_CREATION_DATE: Object

Sorting by creation date. Use with method getPaymentTransactions() as an argument to method FilteringCollection.sort(Object).


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_REVERSE: Object

Reverse orders. Use 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_CAPTURE: Object

Selects the capture transactions. Use with method getPaymentTransactions() as an argument to method FilteringCollection.select(Object).


QUALIFIER_PRODUCTITEMS: Object

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


QUALIFIER_REFUND: Object

Selects the refund transactions. Use with method getPaymentTransactions() 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_FAILED: String = "FAILED"

Constant for Invoice Status Failed.

The invoice handling failed.


STATUS_MANUAL: String = "MANUAL"

Constant for Invoice Status Manual.

The invoice is not paid but will not be handled automatically.

A manual invoice handling (capture or refund) is necessary.


STATUS_NOT_PAID: String = "NOT_PAID"

Constant for Invoice Status Not Paid.

The invoice is not paid and will be handled automatically.


STATUS_PAID: String = "PAID"

Constant for Invoice Status Paid.

The invoice was successfully paid.


TYPE_APPEASEMENT: String = "APPEASEMENT"

Constant for Invoice Type Appeasement.

The invoice was created for an appeasement.

The invoice amount needs to be refunded.


TYPE_RETURN: String = "RETURN"

Constant for Invoice Type Return.

The invoice was created for a return.

The invoice amount needs to be refunded.


TYPE_RETURN_CASE: String = "RETURN_CASE"

Constant for Invoice Type Return Case.

The invoice was created for a return case.

The invoice amount needs to be refunded.


TYPE_SHIPPING: String = "SHIPPING"

Constant for Invoice Type Shipping.

The invoice was created for a shipping order.

The invoice amount needs to be captured.


capturedAmount: Money (read-only)

Returns the sum of the captured amounts. The captured amounts are calculated on the fly.

Associate a payment capture for a OrderPaymentInstrument with an Invoice using addCaptureTransaction(OrderPaymentInstrument, Money).


invoiceNumber: String (read-only)

Returns the invoice number.


items: FilteringCollection (read-only)

Access the collection of InvoiceItems.

This FilteringCollection can be sorted / filtered using:


paymentTransactions: FilteringCollection (read-only)

Returns the payment transactions belonging to this Invoice.

This FilteringCollection can be sorted / filtered using:

See Also:


refundedAmount: Money (read-only)

Returns the sum of the refunded amounts. The refunded amounts are calculated on the fly.

Associate a payment capture for a OrderPaymentInstrument with an Invoice using addRefundTransaction(OrderPaymentInstrument, Money).


status: EnumValue

Returns the invoice status.

The possible values are STATUS_NOT_PAID, STATUS_MANUAL, STATUS_PAID, STATUS_FAILED.


type: EnumValue (read-only)

Returns the invoice type.

The possible values are TYPE_SHIPPING, TYPE_RETURN, TYPE_RETURN_CASE, TYPE_APPEASEMENT.


account(): Boolean

The invoice will be accounted.

It will be captured in case of a shipping invoice and it will be refunded in case of an appeasement, return case or return invoice.

The accounting will be handled in the payment hooks PaymentHooks.capture(Invoice) or PaymentHooks.refund(Invoice). The implementing script could add payment transactions to the invoice. The accompanying business logic will set the status to PAID or FAILED.

The accounting will fail when the invoice state is different to STATUS_NOT_PAID or STATUS_FAILED.

The method implements its own transaction handling. The method must not be called inside a transaction.

Returns:

  • true when the accounting was successful, otherwise false.

addCaptureTransaction(instrument: OrderPaymentInstrument, capturedAmount: Money): PaymentTransaction

Calling this method registers an amount captured for a given order payment instrument. The authorization for the capture is associated with the payment transaction belonging to the instrument. Calling this method allows the Invoice, the OrderPaymentInstrument and the Order to return their captured amount as a sum calculated on the fly. The method may be called multiple times for the same instrument (multiple capture for one authorization) or for different instruments (invoice settlement using multiple payments).

Parameters:

  • instrument - the order payment instrument
  • capturedAmount - amount to register as captured

Returns:

  • the created capture transaction

addRefundTransaction(instrument: OrderPaymentInstrument, refundedAmount: Money): PaymentTransaction

Calling this method registers an amount refunded for a given order payment instrument. Calling this method allows the Invoice, the OrderPaymentInstrument and the Order to return their refunded amount as a sum calculated on the fly. The method may be called multiple times for the same instrument (multiple refunds of one payment) or for different instruments (invoice settlement using multiple payments).

Parameters:

  • instrument - the order payment instrument
  • refundedAmount - amount to register as refunded

Returns:

  • the created refund transaction

getCapturedAmount(): Money

Returns the sum of the captured amounts. The captured amounts are calculated on the fly.

Associate a payment capture for a OrderPaymentInstrument with an Invoice using addCaptureTransaction(OrderPaymentInstrument, Money).

Returns:

  • sum of captured amounts

getInvoiceNumber(): String

Returns the invoice number.

Returns:

  • the invoice number

getItems(): FilteringCollection

Access the collection of InvoiceItems.

This FilteringCollection can be sorted / filtered using:

Returns:

  • the invoice items

getPaymentTransactions(): FilteringCollection

Returns the payment transactions belonging to this Invoice.

This FilteringCollection can be sorted / filtered using:

Returns:

  • the payment transactions.

See Also:


getRefundedAmount(): Money

Returns the sum of the refunded amounts. The refunded amounts are calculated on the fly.

Associate a payment capture for a OrderPaymentInstrument with an Invoice using addRefundTransaction(OrderPaymentInstrument, Money).

Returns:

  • sum of refunded amounts

getStatus(): EnumValue

Returns the invoice status.

The possible values are STATUS_NOT_PAID, STATUS_MANUAL, STATUS_PAID, STATUS_FAILED.

Returns:

  • the invoice status

getType(): EnumValue

Returns the invoice type.

The possible values are TYPE_SHIPPING, TYPE_RETURN, TYPE_RETURN_CASE, TYPE_APPEASEMENT.

Returns:

  • the invoice type

setStatus(status: String): void

Sets the invoice status.

The possible values are STATUS_NOT_PAID, STATUS_MANUAL, STATUS_PAID, STATUS_FAILED.

Parameters:

  • status - the invoice status to set