Documentation
¶
Overview ¶
Package outbound builds the documents the gateway sends to a partner: the 855 (order acknowledgment) and the 856 (ship notice).
Input: a Spec, the typed content of the document that the gateway took from its own records (the order it created, the facts of the warehouse), and an Envelope with the three control numbers and the two interchange ids. Output: the bytes of one X12 004010 interchange, or an error. Nothing here comes from the agent.
Build parses its own output with the strict parser and refuses to return bytes the parser would reject, so the gateway never sends what it could not read itself.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build997 ¶
Build997 writes the 997 for the spec. Values copied from the partner are made to fit the field (length, no separators) first, so a strange ST02 or segment id cannot make the gateway's own bytes unreadable; if the strict parser still refuses them, Build997 returns the error and the caller sends no 997.
Types ¶
type AckSet ¶
AckSet is the verdict on one set: its ST01 and ST02 as the partner sent them and the errors of the strict parser (none means accepted).
type AckSpec ¶
type AckSpec struct {
PartnerID string // ISA05:ISA06 of the receiver of the 997, the partner that sent the group
GroupCode string // GS01 of the group
GroupControl string // GS06 of the group
Sets []AckSet
}
AckSpec describes the 997 for one functional group: GS01 and GS06 of the group and its sets.
type Envelope ¶
Envelope holds what the interchange needs besides the content: the ids of the two sides ("ZZ:ID"), the control numbers and the moment of writing.
type Line ¶
type Line struct {
SKU string `json:"sku"`
Qty string `json:"qty"`
Unit string `json:"unit"`
UnitPrice string `json:"unit_price"`
Status string `json:"status,omitempty"`
SSCC string `json:"sscc,omitempty"`
}
Line is one line of an outgoing document. Qty is a decimal string with at most three places. Status (855 only) is IA (accepted) or IR (rejected). SSCC (856 only) is the pallet label of the line.
type Spec ¶
type Spec struct {
ST01 string `json:"st01"` // 855 or 856
PartnerID string `json:"partner_id"` // ISA05:ISA06 of the receiver
Ref string `json:"ref"` // the order number of the partner (BEG03)
OrderDate string `json:"order_date"` // CCYYMMDD (BEG05)
Currency string `json:"currency"` // ISO 4217
AckType string `json:"ack_type,omitempty"` // 855: AC, AD or RJ
ShipTo string `json:"ship_to,omitempty"` // code of the ship-to place
ShipmentID string `json:"shipment_id,omitempty"` // 856: identification of the shipment (BSN02)
Lines []Line `json:"lines"`
}
Spec is the content of an outgoing document. It is stored as JSON in the request to the operator and in the outbox, so the field names are fixed.
func (Spec) AmountCents ¶
AmountCents is the sum of the document: quantity times price over the lines that are not rejected, in whole cents.