Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

Purchase Order

Josh Horton edited this page Feb 17, 2020 · 6 revisions

Purchase Order -> (layer: 'transaction', label: 'order')

GS1 to JSON mapping

This section shows the GS1 XML to JSON mappings. JSON keys are on the left, and the XPaths to the corresponding tag in GS1 XML are on the right, separated by a colon character (:).

// Context Node: /order:orderMessage/order
{
  "transactionID" : "orderIdentification/entityIdentification",
  "creationDateTime" : "creationDateTime",
  "documentStatusCode" : "documentStatusCode",
  "orderTypeCode": "orderTypeCode",
  "buyerGLN" : "buyer/gln",
  "sellerGLN" : "seller/gln",
  // Context Node: orderLogisticalInformation
  "orderLogisticalInformation" : {
    "shipFromGLN": "shipFrom/gln",
    "shipTo": "shipTo/gln",
    "orderLogisticalDateInforamtion": {
      "requestedDeliveryDateTime": "orderLogisticalDateInformation/requestedDeliveryDateTime"
    }
  }
  // Context Node: orderLineItem
  "orderLineItem" : [
    {
      "lineItemNumber" : "lineItemNumber",
      "transactionalTradeItemGTIN" : "transactionalTradeItem/gtin",
      "requestedQuantity" : "requestedQuantity",
      "requestedQuantityMeasurementUnitCode" : "requestedQuantity/@MeasurementUnitCode"
  ],
  "flatEPCList" : [
    "orderLineItem/transactionalTradeItem/gtin",
    ...
  ]
}

Input

The following example shows a valid GS1 XML file for input. The JSON output follows.

Note: The following fields have been removed for GDPR compliance:

  1. StandardBusinessDocumentHeader.Sender.ContactInformation (all sub-elements)
  2. StandardBusinessDocumentHeader.Receiver.ContactInformation (all sub-elements)
<?xml version="1.0" encoding="UTF-8"?>
<order:orderMessage
    xmlns:order="urn:gs1:ecom:order:xsd:3"
    xmlns:sh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:gs1:ecom:order:xsd:3 ../Schemas/gs1/ecom/Order.xsd">
    <sh:StandardBusinessDocumentHeader>
        <sh:HeaderVersion>1.0</sh:HeaderVersion>
        <sh:Sender>
            <sh:Identifier Authority="GS1"/>
        </sh:Sender>
        <sh:Receiver>
            <sh:Identifier Authority="GS1"/>
        </sh:Receiver>
        <sh:DocumentIdentification>
            <sh:Standard>GS1</sh:Standard>
            <sh:TypeVersion>3.3</sh:TypeVersion>
            <sh:InstanceIdentifier>string</sh:InstanceIdentifier>
            <sh:Type>order</sh:Type>
            <sh:MultipleType>false</sh:MultipleType>
            <sh:CreationDateAndTime>2006-01-10T12:00:01.000-05:00</sh:CreationDateAndTime>
        </sh:DocumentIdentification>
    </sh:StandardBusinessDocumentHeader>
    <order>
        <creationDateTime>2011-03-11T11:00:00.000-05:00</creationDateTime>
        <documentStatusCode>ORIGINAL</documentStatusCode>
        <orderIdentification>
            <entityIdentification>string</entityIdentification>
        </orderIdentification>
        <orderTypeCode>string</orderTypeCode>
        <buyer>
            <gln>string</gln>
        </buyer>
        <seller>
            <gln>string</gln>
        </seller>
        <orderLogisticalInformation>
            <shipFrom>
                <gln>string</gln>
            </shipFrom>
            <shipTo>
                <gln>string</gln>
            </shipTo>
            <orderLogisticalDateInformation>
                <requestedDeliveryDateTime>
                    <date>2011-04-11</date>
                </requestedDeliveryDateTime>
            </orderLogisticalDateInformation>
        </orderLogisticalInformation>
        <orderLineItem>
            <lineItemNumber>1</lineItemNumber>
            <requestedQuantity measurementUnitCode="EA">48</requestedQuantity>
            <transactionalTradeItem>
                <gtin>string</gtin>
            </transactionalTradeItem>
        </orderLineItem>
        <orderLineItem>
            <lineItemNumber>2</lineItemNumber>
            <requestedQuantity measurementUnitCode="EA">24</requestedQuantity>
            <transactionalTradeItem>
                <gtin>string</gtin>
            </transactionalTradeItem>
        </orderLineItem>
    </order>
</order:orderMessage>

Output

The following example shows the JSON output from the input GS1 XML file above.

This is the generated ID:

{
  "id": "urn:transaction:order:security_disabled:default:default:string"
}

This is the generated JSON:

{
  "creationDateTime": "2011-03-11T11:00:00.000-05:00",
  "documentStatusCode": "ORIGINAL",
  "transactionID": "string",
  "orderTypeCode": "string",
  "buyerGLN": "string",
  "sellerGLN": "string",
  "orderLogisticalInformation": [
    {
      "shipFromGLN": "string",
      "shipToGLN": "string",
      "orderLogisticalDateInformation": {
        "requestedDeliveryDateTime": "2011-04-11"
      }
    }
  ],
  "orderLineItems": [
    {
      "lineItemNumber": 1,
      "requestedQuantity": 48,
      "requestedQuantityMeasurementUnitCode": "EA",
      "transactionalTradeItemGTIN": "string"
    },
    {
      "lineItemNumber": 2,
      "requestedQuantity": 24,
      "requestedQuantityMeasurementUnitCode": "EA",
      "transactionalTradeItemGTIN": "string"
    }
  ],
  "flatEPCList": [
    "string"
    "string"
  ]
}
Clone this wiki locally