Documentation
¶
Index ¶
- type BulkDeleteSalesOrdersEndpoint
- type BulkDeleteSalesOrdersRequest
- type CheckoutSalesOrderEndpoint
- type CheckoutSalesOrderRequest
- type CheckoutSalesOrderResponse
- type CloseSalesOrderEndpoint
- type CloseSalesOrderRequest
- type CreateProductionRunEndpoint
- type CreateProductionRunRequest
- type CreateSalesOrderEndpoint
- type CreateSalesOrderLineEndpoint
- type CreateSalesOrderLineInput
- type CreateSalesOrderLineRequest
- type CreateSalesOrderRequest
- type DeleteSalesOrderEndpoint
- type DeleteSalesOrderLineEndpoint
- type DeleteSalesOrderLineRequest
- type DeleteSalesOrderRequest
- type IssueSalesOrderEndpoint
- type IssueSalesOrderRequest
- type ListSalesOrdersEndpoint
- type ListSalesOrdersRequest
- type OpenSalesOrderEndpoint
- type OpenSalesOrderRequest
- type QuoteSalesOrderCommitmentEndpoint
- type QuoteSalesOrderCommitmentRequest
- type QuoteSalesOrderCommitmentResponse
- type QuoteSalesOrderFreightEndpoint
- type QuoteSalesOrderFreightRequest
- type QuoteSalesOrderFreightResponse
- type QuoteSalesOrderLineInput
- type QuoteSalesOrderPricesEndpoint
- type QuoteSalesOrderPricesRequest
- type QuoteSalesOrderPricesResponse
- type QuotedSalesOrderLine
- type ReorderSalesOrderLinesEndpoint
- type ReorderSalesOrderLinesRequest
- type RetrieveSalesOrderEndpoint
- type RetrieveSalesOrderRequest
- type SalesOrderEmailContactInput
- type SalesOrderSvc
- type SalesOrderSvcConfig
- type UnissueSalesOrderEndpoint
- type UnissueSalesOrderRequest
- type UpdateSalesOrderEndpoint
- type UpdateSalesOrderLineEndpoint
- type UpdateSalesOrderLineRequest
- type UpdateSalesOrderRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkDeleteSalesOrdersEndpoint ¶
type BulkDeleteSalesOrdersEndpoint struct{}
Deletes multiple sales orders in a single atomic operation.
Each order is torn down exactly as it would be by deleting it on its own. Fulfilled orders cannot be deleted; if any requested order fails this check, no orders are deleted.
func (*BulkDeleteSalesOrdersEndpoint) Materialize ¶
func (e *BulkDeleteSalesOrdersEndpoint) Materialize() *apiendpoint.APIEndpoint[*BulkDeleteSalesOrdersRequest, *apiresource.EmptyResource]
type BulkDeleteSalesOrdersRequest ¶
type BulkDeleteSalesOrdersRequest struct {
// IDs of the sales orders to delete.
SalesOrderIDs []string `json:"sales_order_ids" validate:"required"`
}
Request to bulk delete sales orders.
func (*BulkDeleteSalesOrdersRequest) SchemaExample ¶
func (*BulkDeleteSalesOrdersRequest) SchemaExample() any
type CheckoutSalesOrderEndpoint ¶
type CheckoutSalesOrderEndpoint struct{}
Creates a hosted payment checkout session for a sales order.
Requires an active Stripe integration on the account and a customer that already exists in Stripe. The customer is charged a single amount covering every line on the order, including its freight and discount lines, and the checkout link is emailed to the address provided. Fails with a conflict if the order already has a payment.
func (*CheckoutSalesOrderEndpoint) Materialize ¶
func (e *CheckoutSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*CheckoutSalesOrderRequest, *CheckoutSalesOrderResponse]
type CheckoutSalesOrderRequest ¶
type CheckoutSalesOrderRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
// Email address to send the checkout link to.
Email string `json:"email" validate:"required,email"`
}
Request to create a checkout session for a sales order.
func (*CheckoutSalesOrderRequest) SchemaExample ¶
func (*CheckoutSalesOrderRequest) SchemaExample() any
type CheckoutSalesOrderResponse ¶
type CheckoutSalesOrderResponse struct {
// Resource type identifier.
Object constants.ObjectType `json:"object" validate:"required,enum=checkout_sales_order"`
// URL of the hosted payment page where the customer completes the checkout.
CheckoutURL string `json:"checkout_url" validate:"required"`
}
Checkout session result.
func (*CheckoutSalesOrderResponse) SchemaExample ¶
func (*CheckoutSalesOrderResponse) SchemaExample() any
type CloseSalesOrderEndpoint ¶
type CloseSalesOrderEndpoint struct{}
Closes a sales order, transitioning it from `issued` to `fulfilled`.
Stamps the order's completion timestamp and closes its pick, packing every pick line that is still open so the pick reads as complete alongside the order. Only an order in `issued` can be closed, and once it is fulfilled it can no longer be deleted, nor can its lines be removed, until it is reopened.
func (*CloseSalesOrderEndpoint) Materialize ¶
func (e *CloseSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*CloseSalesOrderRequest, *apiresource.SalesOrder]
type CloseSalesOrderRequest ¶
type CloseSalesOrderRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
}
Request to close a sales order.
func (*CloseSalesOrderRequest) SchemaExample ¶
func (*CloseSalesOrderRequest) SchemaExample() any
type CreateProductionRunEndpoint ¶
type CreateProductionRunEndpoint struct{}
Creates a production run from a sales order.
Walks the production flow behind each item-backed line to work out what actually has to be made, then creates one batch for each item that is produced directly from raw materials, sized to cover every line that needs it. Reserves the material inventory those batches consume and links the run to the order. The caller becomes the run's responsible user. An order can have at most one production run, and a line whose item has no production flow contributes no batches.
func (*CreateProductionRunEndpoint) Materialize ¶
func (e *CreateProductionRunEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateProductionRunRequest, *apiresource.ProductionRun]
type CreateProductionRunRequest ¶
type CreateProductionRunRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
}
Request to create a production run from a sales order.
type CreateSalesOrderEndpoint ¶
type CreateSalesOrderEndpoint struct{}
Creates a sales order in `estimate` status.
The order number is assigned automatically, and a sales rep is auto-assigned when none is provided. Line prices and costs are resolved server-side from each product. A shipping line carrying the estimated freight charge is added to the order, plus a negative-priced discount line when an order discount is supplied. The order is not committed for fulfillment until it is issued.
func (*CreateSalesOrderEndpoint) Materialize ¶
func (e *CreateSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateSalesOrderRequest, *apiresource.SalesOrder]
type CreateSalesOrderLineEndpoint ¶
type CreateSalesOrderLineEndpoint struct{}
Adds a line item to a sales order.
The new line is appended below the existing product lines, keeping the order's freight and discount lines at the bottom. When the order has already been issued, the line is added to its pick as outstanding work and the pick is reopened if it had been finished.
func (*CreateSalesOrderLineEndpoint) Materialize ¶
func (e *CreateSalesOrderLineEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateSalesOrderLineRequest, *apiresource.SalesOrderLine]
type CreateSalesOrderLineInput ¶
type CreateSalesOrderLineInput struct {
// ID of the product being ordered.
ProductID string `json:"product_id" validate:"required"`
// Quantity ordered.
Quantity apirequest.QuantityInput `json:"quantity" validate:"required"`
// SKU recorded on the line.
//
// Defaults to the product's SKU when omitted.
ProductSKU field.Optional[string] `json:"product_sku,omitzero" validate:"omitempty,max=255"`
// Description recorded on the line.
//
// Defaults to the product's description when omitted.
ProductDescription field.Optional[string] `json:"product_description,omitzero"`
// Unit price override.
//
// Honored only for internal users; for customer accounts it is ignored and the price is calculated server-side.
UnitPrice field.Optional[apirequest.RateInput] `json:"unit_price,omitzero"`
}
Line item input for a create sales order request.
The item, unit cost, and (unless an internal user supplies a `unit_price` override) the unit price are resolved server-side from the product. The quantity unit must belong to the product's unit group.
type CreateSalesOrderLineRequest ¶
type CreateSalesOrderLineRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
// ID of the product being ordered.
ProductID string `json:"product_id" validate:"required"`
// The product SKU recorded on the line.
ProductSKU string `json:"product_sku" validate:"required,max=255"`
// The product description recorded on the line.
ProductDescription field.Optional[string] `json:"product_description,omitzero"`
// Quantity ordered.
//
// The unit must belong to the product's unit group.
Quantity apirequest.QuantityInput `json:"quantity" validate:"required"`
// Unit price override.
//
// When omitted, the line is priced server-side from the product's pricing rules (customer price, unit-conversion and volume discounts, account-price overrides) — the same pricing applied when the order is created. An explicit value is honored only for internal users. The unit cost is always resolved from the product and never taken from the request.
UnitPrice field.Optional[apirequest.RateInput] `json:"unit_price,omitzero"`
}
Request to create a line on a sales order.
func (*CreateSalesOrderLineRequest) SchemaExample ¶
func (*CreateSalesOrderLineRequest) SchemaExample() any
type CreateSalesOrderRequest ¶
type CreateSalesOrderRequest struct {
// ID of the customer account the order is for.
BuyerAccountID string `json:"buyer_account_id" validate:"required"`
// The customer's own purchase order number, for cross-referencing.
//
// Must be unique among your orders for this customer.
CustomerPurchaseOrderNumber field.Optional[string] `json:"customer_purchase_order_number,omitzero" validate:"omitempty,max=255"`
// Free-form note about the order.
Note field.Optional[string] `json:"note,omitzero"`
// ID of the carrier that will ship the order.
//
// Falls back to the customer's default carrier; the order is rejected when neither is available.
CarrierID field.Optional[string] `json:"carrier_id,omitzero" validate:"omitempty"`
// ID of the carrier service level the order ships on.
//
// Falls back to the customer's default service level, but only when `carrier_id` is also omitted — supplying a carrier without a service level leaves the service level unset.
ServiceLevelID field.Optional[string] `json:"service_level_id,omitzero" validate:"omitempty"`
// Who is billed for freight.
//
// - `sender`: the sender pays for shipping.
// - `third_party`: a third party pays for shipping, using the carrier billing account number.
CarrierBillingType field.Optional[constants.CarrierBillingType] `json:"carrier_billing_type,omitzero" validate:"omitempty"`
// Carrier billing account number charged when `carrier_billing_type` is `third_party`.
CarrierBillingAccountNumber field.Optional[string] `json:"carrier_billing_account_number,omitzero" validate:"omitempty,max=255"`
// Fulfillment priority used to rank the order on the shop floor.
PriorityCode constants.PriorityCode `json:"priority_code" validate:"required"`
// ID of the account user to credit as the order's sales rep.
//
// When omitted, a rep is assigned automatically: the customer's default sales rep first, then the sales territory matching the ship-to postal code, then the ship-to state. No rep is assigned when the customer is commission-exempt or every ordered product belongs to a commission-exempt product line.
SalesRepID field.Optional[string] `json:"sales_rep_id,omitzero" validate:"omitempty"`
// ID of the shipping terms for the order.
//
// Falls back to the customer's default shipping term; the order is rejected when neither is available.
ShippingTermID field.Optional[string] `json:"shipping_term_id,omitzero" validate:"omitempty"`
// ID of the payment terms for the order.
//
// Falls back to the customer's default payment term; the order is rejected when neither is available.
PaymentTermID field.Optional[string] `json:"payment_term_id,omitzero" validate:"omitempty"`
// The order-level discount to apply, given as either its ID or its unique code.
//
// The discount is realized as an extra negative-priced line on the order rather than as a separate total.
OrderDiscountID field.Optional[string] `json:"order_discount_id,omitzero" validate:"omitempty"`
// Date delivery is promised to the customer.
//
// The order's ship-by date is worked back from this: the goods have to reach the customer on a day they receive, so transit and both operating calendars are subtracted from it. Mutually exclusive with lead_time_override_days and ship_by_override_date.
PromisedAt field.Optional[time.Time] `json:"promised_at,omitzero"`
// Days between this order being issued and it being due to ship, replacing the customer's standing lead time for this order alone.
//
// Already a ship lead time, so no carrier transit is subtracted from it. Mutually exclusive with promised_at and ship_by_override_date.
LeadTimeOverrideDays field.Optional[int32] `json:"lead_time_override_days,omitzero" validate:"omitempty,gte=0,lte=3650"`
// The exact date the order is due to ship, bypassing transit and the customer's receiving days.
//
// Still moved back to the nearest earlier day the plant ships on, since a date nobody can ship on is not a deadline. Mutually exclusive with promised_at and lead_time_override_days.
ShipByOverrideDate field.Optional[time.Time] `json:"ship_by_override_date,omitzero"`
// Bill-to address ID.
//
// Must reference an existing address on the order's owner or buyer account.
BillToAddressID string `json:"bill_to_address_id" validate:"required"`
// Ship-to address ID.
//
// Must reference an existing address on the order's owner or buyer account.
ShipToAddressID string `json:"ship_to_address_id" validate:"required"`
// The line items to put on the order.
//
// The freight line, and the discount line when `order_discount_id` is supplied, are added on top of these automatically.
Lines []CreateSalesOrderLineInput `json:"lines" validate:"required,min=1,dive"`
// Users who should receive order acknowledgement emails for this order.
//
// Each must be a user on the customer's account.
AcknowledgementEmailContacts []SalesOrderEmailContactInput `json:"acknowledgement_email_contacts,omitzero"`
// Users who should receive invoice emails for this order.
//
// Each must be a user on the customer's account.
InvoiceEmailContacts []SalesOrderEmailContactInput `json:"invoice_email_contacts,omitzero"`
}
Request to create a sales order.
func (*CreateSalesOrderRequest) SchemaExample ¶
func (*CreateSalesOrderRequest) SchemaExample() any
type DeleteSalesOrderEndpoint ¶
type DeleteSalesOrderEndpoint struct{}
Deletes a sales order and all its related records.
Removes the order's lines, pick, shipment and invoice lines, and email contacts, and releases any inventory it had reserved. Fulfilled orders cannot be deleted.
func (*DeleteSalesOrderEndpoint) Materialize ¶
func (e *DeleteSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteSalesOrderRequest, *apiresource.EmptyResource]
type DeleteSalesOrderLineEndpoint ¶
type DeleteSalesOrderLineEndpoint struct{}
Deletes a sales order line and its pick lines.
A line cannot be removed once it has been packed onto a shipment, or once the order is fulfilled, and removing one from an order that is already completed or has a shipped shipment requires an admin. The remaining lines are renumbered so the sequence stays contiguous, and if this was the last line left to pick, the order's pick is deleted and the order falls back to `estimate` with its reserved inventory released.
func (*DeleteSalesOrderLineEndpoint) Materialize ¶
func (e *DeleteSalesOrderLineEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteSalesOrderLineRequest, *apiresource.EmptyResource]
type DeleteSalesOrderLineRequest ¶
type DeleteSalesOrderLineRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
// Sales order line ID.
SalesOrderLineID string `path:"line_id" validate:"required"`
}
Request to delete a sales order line.
type DeleteSalesOrderRequest ¶
type DeleteSalesOrderRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
}
Request to delete a sales order.
type IssueSalesOrderEndpoint ¶
type IssueSalesOrderEndpoint struct{}
Issues a sales order, transitioning it from `estimate` to `issued`.
Issuing commits the order for fulfillment: a pick is created for the order's sale lines and inventory is reserved for each line tied to an inventory item. Only an order still in `estimate` can be issued.
func (*IssueSalesOrderEndpoint) Materialize ¶
func (e *IssueSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*IssueSalesOrderRequest, *apiresource.SalesOrder]
type IssueSalesOrderRequest ¶
type IssueSalesOrderRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
// Whether to notify the customer.
//
// When `true`, an order acknowledgement email with a PDF of the order is sent to the acknowledgement contacts on the order and the order's `acknowledgment_status` becomes `sent`. An order with no acknowledgement contacts sends nothing and leaves its `acknowledgment_status` unchanged.
NotifyCustomer bool `json:"notify_customer"`
}
Request to issue a sales order.
func (*IssueSalesOrderRequest) SchemaExample ¶
func (*IssueSalesOrderRequest) SchemaExample() any
type ListSalesOrdersEndpoint ¶
type ListSalesOrdersEndpoint struct{}
Returns a paginated list of sales orders for the current account, newest first.
A free-text search term (`q`) is matched as an exact value against the order number and the customer purchase order number, and still respects the other filters. Customer accounts calling this endpoint only ever see their own orders.
func (*ListSalesOrdersEndpoint) Materialize ¶
func (e *ListSalesOrdersEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListSalesOrdersRequest, *apiresource.List[apiresource.SalesOrder]]
type ListSalesOrdersRequest ¶
type ListSalesOrdersRequest struct {
apiresource.PaginationRequest
// Restricts results to orders in any of these lifecycle statuses.
StatusCodes []constants.SalesOrderStatusCode `query:"status_codes"`
// Restricts results to orders that have at least one line for any of these inventory items.
ItemIDs []string `query:"item_ids"`
// Restricts results to orders that have at least one line whose product belongs to any of these product lines.
ProductLineIDs []string `query:"product_line_ids"`
// Restricts results to orders placed by any of these customers.
CustomerIDs []string `query:"customer_ids"`
// Restricts results to orders placed by customers belonging to any of these account groups.
CustomerGroupIDs []string `query:"customer_group_ids"`
// Restricts results to orders credited to any of these sales reps.
//
// These are account user IDs, matching the `sales_rep` on the order.
SalesRepIDs []string `query:"sales_rep_ids"`
// Earliest order creation date to include, in `YYYY-MM-DD` format.
StartDate *string `query:"starts_at"`
// Latest order creation date to include, in `YYYY-MM-DD` format.
//
// Compared against the creation timestamp at the start of that day, so orders created later on the end date itself are excluded; pass the following day to include them.
EndDate *string `query:"ends_at"`
// Earliest ship-by date to include, in `YYYY-MM-DD` format. Inclusive of the date itself.
ShipByAfter *string `query:"ship_by_after"`
// Latest ship-by date to include, in `YYYY-MM-DD` format. Inclusive of the date itself.
ShipByBefore *string `query:"ship_by_before"`
// Restricts results to orders that are, or are not, past their ship-by date.
//
// An order is past due when it is still `issued` and its ship-by date has passed. A fulfilled order that shipped late is not past due — it is delivered, and how late it was is a delivery-performance question rather than a backlog one.
PastDue *bool `query:"past_due"`
}
Request to list sales orders.
type OpenSalesOrderEndpoint ¶
type OpenSalesOrderEndpoint struct{}
Reopens a sales order, transitioning it from `fulfilled` back to `issued`.
Clears the order's completion timestamp and reopens its pick, unpacking every pick line that is not yet fully picked so the outstanding work can be resumed; lines already picked in full stay packed. Only an order in `fulfilled` can be reopened.
func (*OpenSalesOrderEndpoint) Materialize ¶
func (e *OpenSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*OpenSalesOrderRequest, *apiresource.SalesOrder]
type OpenSalesOrderRequest ¶
type OpenSalesOrderRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
}
Request to reopen a sales order.
func (*OpenSalesOrderRequest) SchemaExample ¶
func (*OpenSalesOrderRequest) SchemaExample() any
type QuoteSalesOrderCommitmentEndpoint ¶
type QuoteSalesOrderCommitmentEndpoint struct{}
Previews the ship-by date a set of commitment inputs would produce, without creating or changing anything.
Runs the same resolution an order runs when it is issued: a promised delivery date has the customer's receiving days, the carrier's transit, and the plant's shipping days worked back through it, while a lead time or a pinned ship date is snapped onto the next earlier day the plant ships. The returned steps are that derivation in order, so a caller can show why a date is what it is rather than restating the rules.
At most one of `promised_at`, `lead_time_override_days`, and `ship_by_override_date` may be set; they are alternative answers to the same question.
Advisory rather than binding. Carrier transit comes from a lane cache warmed in the background, so a lane nobody has shipped yet quotes against the service level's default or against no transit at all, and the date stamped at issue may differ once the lane has been rated.
func (*QuoteSalesOrderCommitmentEndpoint) Materialize ¶
func (e *QuoteSalesOrderCommitmentEndpoint) Materialize() *apiendpoint.APIEndpoint[*QuoteSalesOrderCommitmentRequest, *QuoteSalesOrderCommitmentResponse]
type QuoteSalesOrderCommitmentRequest ¶
type QuoteSalesOrderCommitmentRequest struct {
// An existing order to preview against. Its customer, ship-to address, carrier, and service level are used, and the commitment fields below replace whatever it currently carries.
//
// Omit it to preview an order that has not been created yet, supplying the parts directly.
SalesOrderID field.Optional[string] `json:"sales_order_id,omitzero" validate:"omitempty"`
// The buying account, used to resolve its lead time and receiving days.
BuyerAccountID field.Optional[string] `json:"buyer_account_id,omitzero" validate:"omitempty"`
// The ship-to address, which decides the destination timezone and the lane transit is quoted on.
ShipToAddressID field.Optional[string] `json:"ship_to_address_id,omitzero" validate:"omitempty"`
// Carrier for the shipment.
CarrierID field.Optional[string] `json:"carrier_id,omitzero" validate:"omitempty"`
// Service level for the shipment, which the lane's transit estimate is keyed on.
ServiceLevelID field.Optional[string] `json:"service_level_id,omitzero" validate:"omitempty"`
// When the order would be issued. Defaults to now, since a lead time is measured from issue and an order built today but issued next week commits to next week's date.
IssuedAt field.Optional[time.Time] `json:"issued_at,omitzero"`
// Date delivery would be promised to the customer.
PromisedAt field.Optional[time.Time] `json:"promised_at,omitzero"`
// Days between issue and the order being due to ship, in place of the customer's standing lead time.
LeadTimeOverrideDays field.Optional[int32] `json:"lead_time_override_days,omitzero" validate:"omitempty,gte=0,lte=3650"`
// The exact date the order would be due to ship.
ShipByOverrideDate field.Optional[time.Time] `json:"ship_by_override_date,omitzero"`
}
Request to preview the ship-by date a set of commitment inputs would produce.
func (*QuoteSalesOrderCommitmentRequest) SchemaExample ¶
func (*QuoteSalesOrderCommitmentRequest) SchemaExample() any
type QuoteSalesOrderCommitmentResponse ¶
type QuoteSalesOrderCommitmentResponse struct {
// Resource type identifier.
Object constants.ObjectType `json:"object" validate:"required,enum=sales_order_commitment_quote"`
// The date the order would be due to ship, or null when no rule resolves one.
ShipByDate *time.Time `json:"ship_by_date"`
// That date at the plant's pickup cutoff — the moment freight would have to be tendered by. Null when the shipping calendar carries no cutoff.
ShipByCutoffAt *time.Time `json:"ship_by_cutoff_at"`
// Calendar days between issue and the ship-by date.
LeadTimeDays *int32 `json:"lead_time_days"`
// Which rule produced the date.
LeadTimeSource *constants.LeadTimeSource `json:"lead_time_source"`
// Days the carrier needs to cover the lane. Null when the lane has never been quoted and the service level carries no default, or when no service level was supplied to quote one on.
TransitDays *int32 `json:"transit_days"`
// Where the transit estimate came from.
TransitSource *constants.TransitSource `json:"transit_source"`
// When freight leaving on the ship-by date would reach the customer: transit walked forward from it and landed on a day their dock receives. Null whenever `transit_days` is, since an arrival with no journey behind it would just be the ship date wearing a different name.
//
// Reported for every basis, including the ones that do not use transit to decide the ship-by date. An order committed on a lead time has the same journey ahead of it; it simply was not worked backwards from.
EstimatedDeliveryDate *time.Time `json:"estimated_delivery_date"`
// Days the receiving and shipping calendars pulled the date back, beyond what transit accounted for.
CalendarAdjustmentDays int32 `json:"calendar_adjustment_days"`
// The derivation in order, one entry per rule that moved the date.
Steps []apiresource.CommitmentQuoteStep `json:"steps"`
}
The ship-by date a set of commitment inputs would produce, and how it was reached.
func (*QuoteSalesOrderCommitmentResponse) SchemaExample ¶
func (*QuoteSalesOrderCommitmentResponse) SchemaExample() any
type QuoteSalesOrderFreightEndpoint ¶
type QuoteSalesOrderFreightEndpoint struct{}
Re-estimates the freight (shipping) charge for an order using the latest carrier rates.
Computes what the order's freight charge would be from its current ship-to address, carrier, service level, and line items — applying the same freight-exemption, flat-rate, and live carrier-rate logic used when the order is created. The order is not modified: the returned amount is a quote to review, and callers apply it by updating the order's shipping line. Use this to refresh freight after changing the address or line items, or at any time to re-price against current rates.
func (*QuoteSalesOrderFreightEndpoint) Materialize ¶
func (e *QuoteSalesOrderFreightEndpoint) Materialize() *apiendpoint.APIEndpoint[*QuoteSalesOrderFreightRequest, *QuoteSalesOrderFreightResponse]
type QuoteSalesOrderFreightRequest ¶
type QuoteSalesOrderFreightRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
}
Request to re-quote an order's freight charge.
type QuoteSalesOrderFreightResponse ¶
type QuoteSalesOrderFreightResponse struct {
// Resource type identifier.
Object constants.ObjectType `json:"object" validate:"required,enum=sales_order_freight_quote"`
// Estimated freight unit price.
UnitPrice *apiresource.ComputedRate `json:"unit_price"`
}
The freshly estimated freight charge for a sales order.
func (*QuoteSalesOrderFreightResponse) SchemaExample ¶
func (*QuoteSalesOrderFreightResponse) SchemaExample() any
type QuoteSalesOrderLineInput ¶
type QuoteSalesOrderLineInput struct {
// ID of the product to price.
ProductID string `json:"product_id" validate:"required"`
// Quantity ordered.
//
// The unit must belong to the product's unit group.
Quantity apirequest.QuantityInput `json:"quantity" validate:"required"`
}
A line to price in a quote request.
type QuoteSalesOrderPricesEndpoint ¶
type QuoteSalesOrderPricesEndpoint struct{}
Calculates the unit price for each line without creating an order.
Use this to display prices to users as they build an order. Prices are computed server-side from the product's list price, contracted account prices, and applicable discounts — the same logic used when an order is created. Internal price overrides are not accepted here; the calculated price is always returned.
func (*QuoteSalesOrderPricesEndpoint) Materialize ¶
func (e *QuoteSalesOrderPricesEndpoint) Materialize() *apiendpoint.APIEndpoint[*QuoteSalesOrderPricesRequest, *QuoteSalesOrderPricesResponse]
type QuoteSalesOrderPricesRequest ¶
type QuoteSalesOrderPricesRequest struct {
// ID of the customer account the prices are for.
BuyerAccountID string `json:"buyer_account_id" validate:"required"`
// Lines to price.
Lines []QuoteSalesOrderLineInput `json:"lines" validate:"required,min=1,dive"`
}
Request to quote sales-order line prices without creating an order.
func (*QuoteSalesOrderPricesRequest) SchemaExample ¶
func (*QuoteSalesOrderPricesRequest) SchemaExample() any
type QuoteSalesOrderPricesResponse ¶
type QuoteSalesOrderPricesResponse struct {
// Resource type identifier.
Object constants.ObjectType `json:"object" validate:"required,enum=sales_order_price_quote"`
// Priced lines, in the same order as the request.
Lines *apiresource.List[QuotedSalesOrderLine] `json:"lines"`
}
Quoted unit prices for the requested lines, in request order.
func (*QuoteSalesOrderPricesResponse) SchemaExample ¶
func (*QuoteSalesOrderPricesResponse) SchemaExample() any
type QuotedSalesOrderLine ¶
type QuotedSalesOrderLine struct {
// Resource type identifier.
Object constants.ObjectType `json:"object" validate:"required,enum=sales_order_price_quote_line"`
// The product priced.
Product *apiresource.Product `json:"product"`
// Calculated unit price.
UnitPrice *apiresource.ComputedRate `json:"unit_price"`
}
One priced line in a quote response.
type ReorderSalesOrderLinesEndpoint ¶
type ReorderSalesOrderLinesEndpoint struct{}
Reorders the product lines on a sales order to match the sequence supplied.
The lines are renumbered from `1` in the given order. Discount and freight lines always stay at the bottom of the list regardless of the sequence given here.
func (*ReorderSalesOrderLinesEndpoint) Materialize ¶
func (e *ReorderSalesOrderLinesEndpoint) Materialize() *apiendpoint.APIEndpoint[*ReorderSalesOrderLinesRequest, *apiresource.EmptyResource]
type ReorderSalesOrderLinesRequest ¶
type ReorderSalesOrderLinesRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
// The order's product-line IDs in the desired display order.
//
// Every product line on the order must be listed exactly once. The automatically generated discount and freight lines are kept at the bottom of the list and must not be included.
LineIDs []string `json:"line_ids" validate:"required,min=1,dive,required"`
}
Request to reorder a sales order's lines.
func (*ReorderSalesOrderLinesRequest) SchemaExample ¶
func (*ReorderSalesOrderLinesRequest) SchemaExample() any
type RetrieveSalesOrderEndpoint ¶
type RetrieveSalesOrderEndpoint struct{}
Returns a sales order by ID.
func (*RetrieveSalesOrderEndpoint) Materialize ¶
func (e *RetrieveSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveSalesOrderRequest, *apiresource.SalesOrder]
type RetrieveSalesOrderRequest ¶
type RetrieveSalesOrderRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
}
Request to retrieve a sales order by ID.
type SalesOrderEmailContactInput ¶
type SalesOrderEmailContactInput struct {
// ID of the account user who should receive the notification.
AccountUserID string `json:"account_user_id" validate:"required"`
}
A user subscribed to one of a sales order's email notifications.
type SalesOrderSvc ¶
type SalesOrderSvc interface {
ListSalesOrders(ctx context.Context, req *ListSalesOrdersRequest) (*apiresource.List[apiresource.SalesOrder], *apierror.APIError)
GetSalesOrder(ctx context.Context, req *RetrieveSalesOrderRequest) (*apiresource.SalesOrder, *apierror.APIError)
CreateSalesOrder(ctx context.Context, req *CreateSalesOrderRequest) (*apiresource.SalesOrder, *apierror.APIError)
UpdateSalesOrder(ctx context.Context, req *UpdateSalesOrderRequest) (*apiresource.SalesOrder, *apierror.APIError)
DeleteSalesOrder(ctx context.Context, req *DeleteSalesOrderRequest) (*apiresource.EmptyResource, *apierror.APIError)
BulkDeleteSalesOrders(ctx context.Context, req *BulkDeleteSalesOrdersRequest) (*apiresource.EmptyResource, *apierror.APIError)
IssueSalesOrder(ctx context.Context, req *IssueSalesOrderRequest) (*apiresource.SalesOrder, *apierror.APIError)
UnissueSalesOrder(ctx context.Context, req *UnissueSalesOrderRequest) (*apiresource.SalesOrder, *apierror.APIError)
CloseSalesOrder(ctx context.Context, req *CloseSalesOrderRequest) (*apiresource.SalesOrder, *apierror.APIError)
OpenSalesOrder(ctx context.Context, req *OpenSalesOrderRequest) (*apiresource.SalesOrder, *apierror.APIError)
CheckoutSalesOrder(ctx context.Context, req *CheckoutSalesOrderRequest) (*CheckoutSalesOrderResponse, *apierror.APIError)
QuoteSalesOrderPrices(ctx context.Context, req *QuoteSalesOrderPricesRequest) (*QuoteSalesOrderPricesResponse, *apierror.APIError)
QuoteSalesOrderFreight(ctx context.Context, req *QuoteSalesOrderFreightRequest) (*QuoteSalesOrderFreightResponse, *apierror.APIError)
QuoteSalesOrderCommitment(ctx context.Context, req *QuoteSalesOrderCommitmentRequest) (*QuoteSalesOrderCommitmentResponse, *apierror.APIError)
CreateSalesOrderProductionRun(ctx context.Context, req *CreateProductionRunRequest) (*apiresource.ProductionRun, *apierror.APIError)
CreateSalesOrderLine(ctx context.Context, req *CreateSalesOrderLineRequest) (*apiresource.SalesOrderLine, *apierror.APIError)
UpdateSalesOrderLine(ctx context.Context, req *UpdateSalesOrderLineRequest) (*apiresource.SalesOrderLine, *apierror.APIError)
DeleteSalesOrderLine(ctx context.Context, req *DeleteSalesOrderLineRequest) (*apiresource.EmptyResource, *apierror.APIError)
ReorderSalesOrderLines(ctx context.Context, req *ReorderSalesOrderLinesRequest) (*apiresource.EmptyResource, *apierror.APIError)
}
func NewSalesOrderSvc ¶
func NewSalesOrderSvc(config *SalesOrderSvcConfig) SalesOrderSvc
type SalesOrderSvcConfig ¶
type SalesOrderSvcConfig struct {
// CoreClient (required) is the core-service sales gRPC client.
CoreClient pb.CoreSalesServiceClient
}
type UnissueSalesOrderEndpoint ¶
type UnissueSalesOrderEndpoint struct{}
Unissues a sales order, transitioning it from `issued` back to `estimate`.
Deletes the order's pick, discarding any picking progress recorded against it, and releases the inventory reserved when the order was issued. Only an order in `issued` can be unissued.
func (*UnissueSalesOrderEndpoint) Materialize ¶
func (e *UnissueSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*UnissueSalesOrderRequest, *apiresource.SalesOrder]
type UnissueSalesOrderRequest ¶
type UnissueSalesOrderRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
}
Request to unissue a sales order.
func (*UnissueSalesOrderRequest) SchemaExample ¶
func (*UnissueSalesOrderRequest) SchemaExample() any
type UpdateSalesOrderEndpoint ¶
type UpdateSalesOrderEndpoint struct{}
Partially updates a sales order.
Changing the carrier, service level, or ship-to address propagates to the order's existing shipments, but never re-prices the freight line: request a fresh estimate from the quote-freight endpoint and apply it to the shipping line yourself. Order status is changed through the issue, unissue, close, and reopen actions instead of this endpoint.
func (*UpdateSalesOrderEndpoint) Materialize ¶
func (e *UpdateSalesOrderEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateSalesOrderRequest, *apiresource.SalesOrder]
type UpdateSalesOrderLineEndpoint ¶
type UpdateSalesOrderLineEndpoint struct{}
Partially updates a sales order line item.
Changing the quantity flows through to fulfillment: the order's pick is reconciled against what is still outstanding — reopening it when the new quantity leaves work to do, or dropping the surplus pick line and finishing it when everything ordered is already packed. Shipment and invoice lines that still carry the full previously ordered quantity follow the new value, while partial ones keep the amount that actually moved.
func (*UpdateSalesOrderLineEndpoint) Materialize ¶
func (e *UpdateSalesOrderLineEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateSalesOrderLineRequest, *apiresource.SalesOrderLine]
type UpdateSalesOrderLineRequest ¶
type UpdateSalesOrderLineRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
// Sales order line ID.
SalesOrderLineID string `path:"line_id" validate:"required"`
// SKU recorded on the line.
ProductSKU field.Optional[string] `json:"product_sku,omitzero" validate:"omitempty,max=255"`
// Description recorded on the line.
ProductDescription field.Clearable[string] `json:"product_description,omitzero"`
// New quantity ordered on the line.
Quantity field.Optional[apirequest.QuantityInput] `json:"quantity,omitzero" validate:"omitempty"`
// Price charged per unit.
//
// Rounded to the nearest cent.
UnitPrice field.Optional[apirequest.RateInput] `json:"unit_price,omitzero" validate:"omitempty"`
// Internal cost per unit, used to derive line profitability.
//
// Rounded to the nearest cent.
UnitCost field.Optional[apirequest.RateInput] `json:"unit_cost,omitzero" validate:"omitempty"`
}
Request to update a sales order line.
func (*UpdateSalesOrderLineRequest) SchemaExample ¶
func (*UpdateSalesOrderLineRequest) SchemaExample() any
type UpdateSalesOrderRequest ¶
type UpdateSalesOrderRequest struct {
// Sales order ID.
SalesOrderID string `path:"id" validate:"required"`
// The customer's own purchase order number, for cross-referencing.
CustomerPurchaseOrderNumber field.Clearable[string] `json:"customer_purchase_order_number,omitzero" validate:"omitempty,max=255"`
// Free-form note about the order.
Note field.Clearable[string] `json:"note,omitzero"`
// ID of the carrier that will ship the order.
CarrierID field.Optional[string] `json:"carrier_id,omitzero" validate:"omitempty"`
// ID of the carrier service level the order ships on.
ServiceLevelID field.Clearable[string] `json:"service_level_id,omitzero" validate:"omitempty"`
// Who is billed for freight.
//
// - `sender`: the sender pays for shipping.
// - `third_party`: a third party pays for shipping, using the carrier billing account number.
CarrierBillingType field.Clearable[constants.CarrierBillingType] `json:"carrier_billing_type,omitzero" validate:"omitempty"`
// Carrier billing account number charged when `carrier_billing_type` is `third_party`.
CarrierBillingAccountNumber field.Clearable[string] `json:"carrier_billing_account_number,omitzero" validate:"omitempty,max=255"`
// New fulfillment priority for the order.
PriorityCode field.Optional[constants.PriorityCode] `json:"priority_code,omitzero" validate:"omitempty"`
// ID of the account user to credit as the order's sales rep.
SalesRepID field.Clearable[string] `json:"sales_rep_id,omitzero" validate:"omitempty"`
// ID of the shipping terms for the order.
ShippingTermID field.Optional[string] `json:"shipping_term_id,omitzero" validate:"omitempty"`
// ID of the payment terms for the order.
PaymentTermID field.Optional[string] `json:"payment_term_id,omitzero" validate:"omitempty"`
// ID of the order-level discount recorded on the order.
//
// Changing this does not add, reprice, or remove the order's discount line; adjust that line directly.
OrderDiscountID field.Clearable[string] `json:"order_discount_id,omitzero" validate:"omitempty"`
// Billing address ID.
//
// Re-points the order to an existing address. To change an address's contents, use the update-address endpoint.
BillingAddressID field.Optional[string] `json:"billing_address_id,omitzero" validate:"omitempty"`
// Shipping address ID.
//
// Re-points the order to an existing address. To change an address's contents, use the update-address endpoint.
ShippingAddressID field.Optional[string] `json:"shipping_address_id,omitzero" validate:"omitempty"`
// Acknowledgment status of the order.
//
// Set to `sent` to mark the acknowledgement as sent without emailing the customer, or `not_sent` to reset it.
AcknowledgmentStatus field.Optional[constants.AcknowledgmentStatus] `json:"acknowledgment_status,omitzero" validate:"omitempty"`
// Date delivery is promised to the customer.
PromisedAt field.Clearable[time.Time] `json:"promised_at,omitzero"`
// Days between this order being issued and it being due to ship, replacing the customer's standing lead time for this order alone. Mutually exclusive with promised_at and ship_by_override_date; clear one to switch to another.
LeadTimeOverrideDays field.Clearable[int32] `json:"lead_time_override_days,omitzero" validate:"omitempty,gte=0,lte=3650"`
// The exact date the order is due to ship, bypassing transit and the customer's receiving days. Mutually exclusive with promised_at and lead_time_override_days.
ShipByOverrideDate field.Clearable[time.Time] `json:"ship_by_override_date,omitzero"`
// Moves the order to a different customer account.
//
// Existing lines keep the prices they were created with; they are not re-priced against the new customer.
CustomerID field.Optional[string] `json:"customer_id,omitzero" validate:"omitempty"`
// Replaces the acknowledgement email contacts on the order.
//
// An empty list clears all contacts; omitting the field leaves existing contacts untouched.
AcknowledgementEmailContacts field.Optional[[]SalesOrderEmailContactInput] `json:"acknowledgement_email_contacts,omitzero"`
// Replaces the invoice email contacts on the order.
//
// An empty list clears all contacts; omitting the field leaves existing contacts untouched.
InvoiceEmailContacts field.Optional[[]SalesOrderEmailContactInput] `json:"invoice_email_contacts,omitzero"`
}
Request to update a sales order.
func (*UpdateSalesOrderRequest) SchemaExample ¶
func (*UpdateSalesOrderRequest) SchemaExample() any
Source Files
¶
- endpoint_bulk_delete_sales_orders.go
- endpoint_checkout_sales_order.go
- endpoint_close_sales_order.go
- endpoint_create_production_run.go
- endpoint_create_sales_order.go
- endpoint_create_sales_order_line.go
- endpoint_delete_sales_order.go
- endpoint_delete_sales_order_line.go
- endpoint_issue_sales_order.go
- endpoint_list_sales_orders.go
- endpoint_open_sales_order.go
- endpoint_quote_sales_order_commitment.go
- endpoint_quote_sales_order_freight.go
- endpoint_quote_sales_order_prices.go
- endpoint_reorder_sales_order_lines.go
- endpoint_retrieve_sales_order.go
- endpoint_unissue_sales_order.go
- endpoint_update_sales_order.go
- endpoint_update_sales_order_line.go
- schema_examples.go
- service.go