Documentation
¶
Overview ¶
Package document holds the types of the stored document body and reads it back for the agent.
Input: the stored JSON (Decode) or an x12.Set of a 997 (BuildAck). Output: the typed header and lines of an 850 or 810, or the body of a 997. Money and quantities are decimal strings written as JSON numbers (json.Number), never float64.
The body of an 850 or 810 is not made here: internal/sanitize builds it through the white list of elements and their formats, and puts every free text into notes. This package only gives that code the types and the number helpers (Decimal, ImpliedDecimal, ISODate).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decimal ¶
Decimal turns an X12 R value (digits, one point, optional minus) into a valid JSON number: no leading zeros, no bare point, no negative zero.
func ISODate ¶
ISODate turns CCYYMMDD into CCYY-MM-DD. The dictionary already guarantees the shape; anything else comes back unchanged.
func ImpliedDecimal ¶
ImpliedDecimal turns an N2 value ("5250" with two implied decimals) into "52.50".
Types ¶
type Ack ¶
type Ack struct {
GroupCode string `json:"group_code"` // AK101
GroupControl string `json:"group_control"` // AK102
Sets []AckSet `json:"sets"`
GroupAck string `json:"group_ack"` // AK901
Included string `json:"included"` // AK902
Received string `json:"received"` // AK903
Accepted string `json:"accepted"` // AK904
}
Ack is the body of a 997. The gateway reads it (wave 2-7); the agent never sees it.
type AckSet ¶
type AckSet struct {
SetID string `json:"set_id"` // AK201
Control string `json:"control"` // AK202
Ack string `json:"ack"` // AK501
Errors []string `json:"errors"` // AK502..AK506
}
AckSet is one AK2..AK5 pair of a 997.
type Header810 ¶
type Header810 struct {
PartnerID string `json:"partner_id"`
BusinessRef string `json:"business_ref"` // BIG02
InvoiceDate string `json:"invoice_date"` // BIG01, YYYY-MM-DD
OrderRef *string `json:"order_ref"` // BIG04
Currency *string `json:"currency"` // CUR02
TotalAmount json.Number `json:"total_amount"` // TDS01 with two implied decimals
ShipTo *string `json:"ship_to"` // N1-04 of the N1 loop with N1-01 = ST
Buyer *string `json:"buyer"` // N1-04 of the N1 loop with N1-01 = BY
References []Reference `json:"references"` // REF01 and REF02 of the heading
}
Header810 is the header of an invoice.
type Header850 ¶
type Header850 struct {
PartnerID string `json:"partner_id"`
BusinessRef string `json:"business_ref"` // BEG03
Purpose string `json:"purpose"` // BEG01
OrderType string `json:"order_type"` // BEG02
OrderDate string `json:"order_date"` // BEG05, YYYY-MM-DD
Currency *string `json:"currency"` // CUR02
ShipTo *string `json:"ship_to"` // N1-04 of the N1 loop with N1-01 = ST
Buyer *string `json:"buyer"` // N1-04 of the N1 loop with N1-01 = BY
References []Reference `json:"references"` // REF01 and REF02 of the heading
}
Header850 is the header of a purchase order.
type Line ¶
type Line struct {
LineNo *string `json:"line_no"`
Qty *json.Number `json:"qty"`
Unit *string `json:"unit"`
UnitPrice *json.Number `json:"unit_price"`
SKU *string `json:"sku"`
SKUQualifier *string `json:"sku_qualifier"`
}
Line is one PO1 or IT1 loop. Every value is optional in the standard.