exchange

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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