{
  "$defs": {
    "__schema0": {
      "const": "1.0",
      "type": "string"
    },
    "__schema1": {
      "items": {
        "$ref": "#/$defs/__schema2"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema10": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "items": {
            "$ref": "#/$defs/__schema10"
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/__schema10"
          },
          "propertyNames": {
            "type": "string"
          },
          "type": "object"
        }
      ]
    },
    "__schema100": {
      "maximum": 9007199254740991,
      "minimum": 0,
      "type": "integer"
    },
    "__schema101": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema102": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema103": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema104": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema105": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema11": {
      "items": {
        "$ref": "#/$defs/__schema12"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema12": {
      "maxLength": 5000,
      "minLength": 1,
      "type": "string"
    },
    "__schema13": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema14": {
      "const": "purchase_order",
      "type": "string"
    },
    "__schema15": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema16": {
      "enum": [
        "original",
        "replacement",
        "duplicate"
      ],
      "type": "string"
    },
    "__schema17": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema18": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema19"
        },
        {
          "$ref": "#/$defs/__schema20"
        }
      ],
      "description": "An ISO 8601 date or timestamp"
    },
    "__schema19": {
      "description": "An ISO 8601 calendar date",
      "format": "date",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
      "type": "string"
    },
    "__schema2": {
      "additionalProperties": false,
      "description": "A typed business reference",
      "properties": {
        "description": {
          "$ref": "#/$defs/__schema6"
        },
        "extensions": {
          "$ref": "#/$defs/__schema7"
        },
        "issuer": {
          "$ref": "#/$defs/__schema5"
        },
        "type": {
          "$ref": "#/$defs/__schema3"
        },
        "value": {
          "$ref": "#/$defs/__schema4"
        }
      },
      "required": [
        "type",
        "value"
      ],
      "type": "object"
    },
    "__schema20": {
      "description": "An ISO 8601 timestamp with a UTC offset",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
      "type": "string"
    },
    "__schema21": {
      "$ref": "#/$defs/__schema22"
    },
    "__schema22": {
      "description": "ISO 4217 currency code",
      "pattern": "^[A-Z]{3}$",
      "type": "string"
    },
    "__schema23": {
      "items": {
        "$ref": "#/$defs/__schema24"
      },
      "maxItems": 100,
      "minItems": 1,
      "type": "array"
    },
    "__schema24": {
      "additionalProperties": false,
      "description": "A business party participating in a document",
      "properties": {
        "address": {
          "$ref": "#/$defs/__schema34"
        },
        "contacts": {
          "$ref": "#/$defs/__schema42"
        },
        "extensions": {
          "$ref": "#/$defs/__schema50"
        },
        "identifiers": {
          "$ref": "#/$defs/__schema26"
        },
        "name": {
          "$ref": "#/$defs/__schema33"
        },
        "role": {
          "$ref": "#/$defs/__schema25"
        }
      },
      "required": [
        "role",
        "identifiers"
      ],
      "type": "object"
    },
    "__schema25": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema26": {
      "items": {
        "$ref": "#/$defs/__schema27"
      },
      "maxItems": 100,
      "minItems": 1,
      "type": "array"
    },
    "__schema27": {
      "additionalProperties": false,
      "description": "A value qualified by an identifier scheme",
      "properties": {
        "agency": {
          "$ref": "#/$defs/__schema30"
        },
        "description": {
          "$ref": "#/$defs/__schema31"
        },
        "extensions": {
          "$ref": "#/$defs/__schema32"
        },
        "scheme": {
          "$ref": "#/$defs/__schema28"
        },
        "value": {
          "$ref": "#/$defs/__schema29"
        }
      },
      "required": [
        "scheme",
        "value"
      ],
      "type": "object"
    },
    "__schema28": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema29": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema3": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema30": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema31": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema32": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema33": {
      "maxLength": 300,
      "minLength": 1,
      "type": "string"
    },
    "__schema34": {
      "additionalProperties": false,
      "description": "A postal address with country-neutral field names",
      "properties": {
        "administrativeArea": {
          "$ref": "#/$defs/__schema38"
        },
        "countryCode": {
          "$ref": "#/$defs/__schema40"
        },
        "extensions": {
          "$ref": "#/$defs/__schema41"
        },
        "lines": {
          "$ref": "#/$defs/__schema35"
        },
        "locality": {
          "$ref": "#/$defs/__schema37"
        },
        "postalCode": {
          "$ref": "#/$defs/__schema39"
        }
      },
      "required": [
        "lines",
        "countryCode"
      ],
      "type": "object"
    },
    "__schema35": {
      "items": {
        "$ref": "#/$defs/__schema36"
      },
      "maxItems": 5,
      "minItems": 1,
      "type": "array"
    },
    "__schema36": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema37": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema38": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema39": {
      "maxLength": 40,
      "minLength": 1,
      "type": "string"
    },
    "__schema4": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema40": {
      "description": "ISO 3166-1 alpha-2 country code",
      "pattern": "^[A-Z]{2}$",
      "type": "string"
    },
    "__schema41": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema42": {
      "items": {
        "$ref": "#/$defs/__schema43"
      },
      "maxItems": 100,
      "type": "array"
    },
    "__schema43": {
      "additionalProperties": false,
      "description": "Contact information associated with a party",
      "properties": {
        "department": {
          "$ref": "#/$defs/__schema46"
        },
        "email": {
          "$ref": "#/$defs/__schema47"
        },
        "extensions": {
          "$ref": "#/$defs/__schema49"
        },
        "name": {
          "$ref": "#/$defs/__schema45"
        },
        "phone": {
          "$ref": "#/$defs/__schema48"
        },
        "role": {
          "$ref": "#/$defs/__schema44"
        }
      },
      "type": "object"
    },
    "__schema44": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema45": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema46": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema47": {
      "format": "email",
      "maxLength": 320,
      "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
      "type": "string"
    },
    "__schema48": {
      "maxLength": 50,
      "minLength": 1,
      "type": "string"
    },
    "__schema49": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema5": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema50": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema51": {
      "$ref": "#/$defs/__schema52"
    },
    "__schema52": {
      "additionalProperties": false,
      "description": "An inclusive business date or timestamp range",
      "properties": {
        "end": {
          "$ref": "#/$defs/__schema54"
        },
        "start": {
          "$ref": "#/$defs/__schema53"
        }
      },
      "type": "object"
    },
    "__schema53": {
      "$ref": "#/$defs/__schema18"
    },
    "__schema54": {
      "$ref": "#/$defs/__schema18"
    },
    "__schema55": {
      "additionalProperties": false,
      "description": "Informational commercial payment terms",
      "properties": {
        "code": {
          "$ref": "#/$defs/__schema56"
        },
        "description": {
          "$ref": "#/$defs/__schema57"
        },
        "discountDate": {
          "$ref": "#/$defs/__schema59"
        },
        "discountPercentage": {
          "$ref": "#/$defs/__schema60"
        },
        "dueDate": {
          "$ref": "#/$defs/__schema58"
        },
        "extensions": {
          "$ref": "#/$defs/__schema62"
        }
      },
      "type": "object"
    },
    "__schema56": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema57": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema58": {
      "$ref": "#/$defs/__schema19"
    },
    "__schema59": {
      "$ref": "#/$defs/__schema19"
    },
    "__schema6": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema60": {
      "$ref": "#/$defs/__schema61"
    },
    "__schema61": {
      "description": "A base-10 decimal value without exponent notation",
      "maxLength": 100,
      "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
      "type": "string"
    },
    "__schema62": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema63": {
      "items": {
        "$ref": "#/$defs/__schema64"
      },
      "maxItems": 50000,
      "minItems": 1,
      "type": "array"
    },
    "__schema64": {
      "additionalProperties": false,
      "description": "A purchase-order line",
      "properties": {
        "allowanceCharges": {
          "$ref": "#/$defs/__schema81"
        },
        "extensions": {
          "$ref": "#/$defs/__schema90"
        },
        "lineNumber": {
          "$ref": "#/$defs/__schema65"
        },
        "orderedQuantity": {
          "$ref": "#/$defs/__schema71"
        },
        "product": {
          "$ref": "#/$defs/__schema66"
        },
        "references": {
          "$ref": "#/$defs/__schema80"
        },
        "requestedDelivery": {
          "$ref": "#/$defs/__schema78"
        },
        "shipTo": {
          "$ref": "#/$defs/__schema79"
        },
        "unitPrice": {
          "$ref": "#/$defs/__schema75"
        }
      },
      "required": [
        "lineNumber",
        "product",
        "orderedQuantity"
      ],
      "type": "object"
    },
    "__schema65": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema66": {
      "additionalProperties": false,
      "description": "A product identified independently of any one industry",
      "properties": {
        "classifications": {
          "$ref": "#/$defs/__schema69"
        },
        "description": {
          "$ref": "#/$defs/__schema68"
        },
        "extensions": {
          "$ref": "#/$defs/__schema70"
        },
        "identifiers": {
          "$ref": "#/$defs/__schema67"
        }
      },
      "required": [
        "identifiers"
      ],
      "type": "object"
    },
    "__schema67": {
      "items": {
        "$ref": "#/$defs/__schema27"
      },
      "maxItems": 100,
      "minItems": 1,
      "type": "array"
    },
    "__schema68": {
      "maxLength": 1000,
      "minLength": 1,
      "type": "string"
    },
    "__schema69": {
      "items": {
        "$ref": "#/$defs/__schema27"
      },
      "maxItems": 100,
      "type": "array"
    },
    "__schema7": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema70": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema71": {
      "additionalProperties": false,
      "description": "A precision-safe quantity and unit",
      "properties": {
        "extensions": {
          "$ref": "#/$defs/__schema74"
        },
        "qualifier": {
          "$ref": "#/$defs/__schema73"
        },
        "unitCode": {
          "$ref": "#/$defs/__schema72"
        },
        "value": {
          "$ref": "#/$defs/__schema61"
        }
      },
      "required": [
        "value",
        "unitCode"
      ],
      "type": "object"
    },
    "__schema72": {
      "description": "A mutually agreed unit-of-measure code",
      "maxLength": 20,
      "minLength": 1,
      "type": "string"
    },
    "__schema73": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema74": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema75": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema76": {
      "additionalProperties": false,
      "description": "A precision-safe monetary amount",
      "properties": {
        "amount": {
          "$ref": "#/$defs/__schema61"
        },
        "currency": {
          "$ref": "#/$defs/__schema22"
        },
        "extensions": {
          "$ref": "#/$defs/__schema77"
        }
      },
      "required": [
        "amount",
        "currency"
      ],
      "type": "object"
    },
    "__schema77": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema78": {
      "$ref": "#/$defs/__schema52"
    },
    "__schema79": {
      "$ref": "#/$defs/__schema24"
    },
    "__schema8": {
      "additionalProperties": {
        "$ref": "#/$defs/__schema10"
      },
      "description": "Namespaced, JSON-compatible extension values",
      "propertyNames": {
        "$ref": "#/$defs/__schema9"
      },
      "type": "object"
    },
    "__schema80": {
      "items": {
        "$ref": "#/$defs/__schema2"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema81": {
      "items": {
        "$ref": "#/$defs/__schema82"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema82": {
      "additionalProperties": false,
      "description": "A monetary allowance or charge",
      "properties": {
        "amount": {
          "$ref": "#/$defs/__schema86"
        },
        "basisAmount": {
          "$ref": "#/$defs/__schema88"
        },
        "code": {
          "$ref": "#/$defs/__schema84"
        },
        "description": {
          "$ref": "#/$defs/__schema85"
        },
        "extensions": {
          "$ref": "#/$defs/__schema89"
        },
        "kind": {
          "$ref": "#/$defs/__schema83"
        },
        "percentage": {
          "$ref": "#/$defs/__schema87"
        }
      },
      "required": [
        "kind"
      ],
      "type": "object"
    },
    "__schema83": {
      "enum": [
        "allowance",
        "charge"
      ],
      "type": "string"
    },
    "__schema84": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema85": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema86": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema87": {
      "$ref": "#/$defs/__schema61"
    },
    "__schema88": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema89": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema9": {
      "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*:[A-Za-z][A-Za-z0-9_.-]*$",
      "type": "string"
    },
    "__schema90": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema91": {
      "items": {
        "$ref": "#/$defs/__schema82"
      },
      "maxItems": 10000,
      "type": "array"
    },
    "__schema92": {
      "items": {
        "$ref": "#/$defs/__schema93"
      },
      "maxItems": 10000,
      "type": "array"
    },
    "__schema93": {
      "additionalProperties": false,
      "description": "A tax amount and its optional calculation basis",
      "properties": {
        "amount": {
          "$ref": "#/$defs/__schema76"
        },
        "extensions": {
          "$ref": "#/$defs/__schema98"
        },
        "jurisdiction": {
          "$ref": "#/$defs/__schema95"
        },
        "rate": {
          "$ref": "#/$defs/__schema96"
        },
        "taxableAmount": {
          "$ref": "#/$defs/__schema97"
        },
        "type": {
          "$ref": "#/$defs/__schema94"
        }
      },
      "required": [
        "type",
        "amount"
      ],
      "type": "object"
    },
    "__schema94": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema95": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema96": {
      "$ref": "#/$defs/__schema61"
    },
    "__schema97": {
      "$ref": "#/$defs/__schema76"
    },
    "__schema98": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema99": {
      "additionalProperties": false,
      "description": "Purchase-order control and monetary totals",
      "properties": {
        "allowanceAmount": {
          "$ref": "#/$defs/__schema102"
        },
        "chargeAmount": {
          "$ref": "#/$defs/__schema103"
        },
        "lineItemCount": {
          "$ref": "#/$defs/__schema100"
        },
        "merchandiseAmount": {
          "$ref": "#/$defs/__schema101"
        },
        "taxAmount": {
          "$ref": "#/$defs/__schema104"
        },
        "totalAmount": {
          "$ref": "#/$defs/__schema105"
        }
      },
      "required": [
        "lineItemCount"
      ],
      "type": "object"
    }
  },
  "$id": "urn:loomedi:canonical:v1:purchase-order",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "A canonical purchase order, commonly mapped from X12 850",
  "properties": {
    "allowanceCharges": {
      "$ref": "#/$defs/__schema91"
    },
    "currency": {
      "$ref": "#/$defs/__schema21"
    },
    "documentType": {
      "$ref": "#/$defs/__schema14"
    },
    "extensions": {
      "$ref": "#/$defs/__schema13"
    },
    "lines": {
      "$ref": "#/$defs/__schema63"
    },
    "notes": {
      "$ref": "#/$defs/__schema11"
    },
    "orderedAt": {
      "$ref": "#/$defs/__schema18"
    },
    "parties": {
      "$ref": "#/$defs/__schema23"
    },
    "paymentTerms": {
      "$ref": "#/$defs/__schema55"
    },
    "purchaseOrderNumber": {
      "$ref": "#/$defs/__schema15"
    },
    "purpose": {
      "$ref": "#/$defs/__schema16"
    },
    "references": {
      "$ref": "#/$defs/__schema1"
    },
    "requestedDelivery": {
      "$ref": "#/$defs/__schema51"
    },
    "revision": {
      "$ref": "#/$defs/__schema17"
    },
    "schemaVersion": {
      "$ref": "#/$defs/__schema0"
    },
    "taxes": {
      "$ref": "#/$defs/__schema92"
    },
    "totals": {
      "$ref": "#/$defs/__schema99"
    }
  },
  "required": [
    "schemaVersion",
    "documentType",
    "purchaseOrderNumber",
    "purpose",
    "orderedAt",
    "parties",
    "lines"
  ],
  "title": "PurchaseOrder",
  "type": "object"
}
