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 Jan 20, 2021 · 6 revisions

Purchase Order

This page describes the XML to JSON mappings for Purchase 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

{

"assetIdUri": "urn:ibm:provenance:asset:transaction:order:<string>:default:default:<string>",
"organization": "<string>",
"layer": "transaction",
"label": "order",
"data":

{
  "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: referencedOrder
  "referencedOrder" : [ {
    "entityIdentification" : "entityIdentification",
    "lineItemNumber" : "lineItemNumber",
    "orderRelationship" : "orderRelationship"
  } ],
  "isReturnOrder" : "extension/isReturnOrder"
  // Context Node: orderLineItem
  "orderLineItem" : [
    {
      "lineItemNumber" : "lineItemNumber",
      "transactionalTradeItemGTIN" : "transactionalTradeItem/gtin",
      "requestedQuantity" : "requestedQuantity",
      "requestedQuantityMeasurementUnitCode" : "requestedQuantity/@MeasurementUnitCode",
      // Context Node: itemPriceBaseQuantity
      "itemPriceBaseQuantity" : {
        "quantity" : "itemPriceBaseQuantity",
        "uom" : "itemPriceBaseQuantity/@MeasurementUnitCode"
      },
    // Context Node: referencedOrder
    "referencedOrder" : [ {
      "entityIdentification" : "entityIdentification",
      "lineItemNumber" : "lineItemNumber",
      "orderRelationship" : "orderRelationship"
    } ],
    "returnReasonCode" : "returnReasonCode",
    // Context Node: extension
    "extension" : {
      "epcList" : "epcList",
      // Context Node: quantityList
      "quantityList" : [ {
        "epcClass" : "epcClass",
        "quantity" : "quantity",
        "quantity_uom" : "uom"
      } ]
    }
  ],
  "flatGTINList" : [
    "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>
        <referencedOrder>
            <entityIdentification>string</entityIdentification>
            <lineItemNumber>2</lineItemNumber>
            <orderRelationship>RELATED</orderRelationship>
        </referencedOrder>
        <extension>
            <isReturnOrder>true</isReturnOrder>
        </extension>
        <orderLineItem>
            <lineItemNumber>1</lineItemNumber>
            <requestedQuantity measurementUnitCode="EA">48</requestedQuantity>
            <itemPriceBaseQuantity measurementUnitCode="KGM">48</itemPriceBaseQuantity>
            <transactionalTradeItem>
                <gtin>string</gtin>
            </transactionalTradeItem>
            <referencedOrder>
                <entityIdentification>string</entityIdentification>
                <lineItemNumber>2</lineItemNumber>
                <orderRelationship>string</orderRelationship>
            </referencedOrder>
            <returnReasonCode>27</returnReasonCode>
        </orderLineItem>
        <orderLineItem>
            <lineItemNumber>2</lineItemNumber>
            <requestedQuantity measurementUnitCode="EA">24</requestedQuantity>
            <itemPriceBaseQuantity measurementUnitCode="KGM">24</itemPriceBaseQuantity>
            <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-05:00",
    "documentStatusCode": "ORIGINAL",
    "transactionID": "string",
    "orderTypeCode": "string",
    "buyerGLN": "string",
    "sellerGLN": "string",
    "orderLogisticalInformation": {
        "shipFromGLN": "string",
        "shipToGLN": "string",
        "orderLogisticalDateInformation": {
            "requestedDeliveryDateTime": "2011-04-11T00:00:00Z"
        }
    },
    "orderLineItems": [
        {
            "lineItemNumber": 1,
            "transactionalTradeItemGTIN": "string",
            "requestedQuantity": 48,
            "requestedQuantityMeasurementUnitCode": "EA",
            "itemPriceBaseQuantity": {
                "quantity": 48,
                "uom": "KGM"
            },
            "referencedOrder": {
                "entityIdentification": "string",
                "lineItemNumber": 2,
                "orderRelationship": "string"
            },
            "returnReasonCode": "27"
        },
        {
            "lineItemNumber": 2,
            "transactionalTradeItemGTIN": "string",
            "requestedQuantity": 24,
            "requestedQuantityMeasurementUnitCode": "EA",
            "itemPriceBaseQuantity": {
                "quantity": 24,
                "uom": "KGM"
            }
        }
    ],
    "flatGTINList": [
        "string"
    ],
    "referencedOrder": [
        {
            "entityIdentification": "string",
            "lineItemNumber": 2,
            "orderRelationship": "RELATED"
        }
    ],
    "isReturnOrder": true
}
Clone this wiki locally