exchange

package
v1.799.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Overview

Package exchange is the order-exchange domain (Medusa v2 core parity): an exchange pairs a return of inbound items on an order with outbound replacement items. The net money movement is DifferenceDueCents — positive when the customer owes the difference, negative when a refund is due.

Index

Constants

View Source
const (
	StatusRequested = "requested"
	StatusConfirmed = "confirmed"
	StatusCanceled  = "canceled"
)

Exchange lifecycle states.

Variables

This section is empty.

Functions

func Query

Types

type Exchange

type Exchange struct {
	mixin.Model[Exchange]

	OrderId string `json:"orderId"`

	// ReturnId links the return that carries the inbound items.
	ReturnId string `json:"returnId,omitempty"`

	// DifferenceDueCents > 0 means the customer owes; < 0 means a refund is due.
	DifferenceDueCents currency.Cents `json:"differenceDueCents"`
	CurrencyCode       currency.Type  `json:"currencyCode" orm:"default:usd"`

	Status string `json:"status" orm:"default:requested"`

	NoNotification bool `json:"noNotification"`

	InboundItems  []ExchangeItem `json:"inboundItems,omitempty" datastore:"-"`
	InboundItems_ string         `json:"-" datastore:",noindex"`

	OutboundItems  []ExchangeItem `json:"outboundItems,omitempty" datastore:"-"`
	OutboundItems_ string         `json:"-" datastore:",noindex"`

	Metadata  Map    `json:"metadata,omitempty" datastore:"-"`
	Metadata_ string `json:"-" datastore:",noindex"`
}

Exchange links a return of InboundItems on an order to OutboundItems shipped in their place. DifferenceDueCents is the net owed (>0) or refundable (<0) amount. An exchange is open until it is confirmed or canceled.

func New

func New(db *datastore.Datastore) *Exchange

func (*Exchange) IsOpen

func (e *Exchange) IsOpen() bool

IsOpen reports whether the exchange is still awaiting confirmation or cancellation.

func (*Exchange) Load

func (e *Exchange) Load(ps []datastore.Property) (err error)

func (*Exchange) Save

func (e *Exchange) Save() ([]datastore.Property, error)

type ExchangeItem

type ExchangeItem struct {
	ItemId   string `json:"itemId"`
	Quantity int    `json:"quantity"`
}

ExchangeItem is a single line of an exchange, referencing an order line item by ItemId with the quantity being returned (inbound) or shipped (outbound).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL