"$schema": https://json-schema.org/draft/2020-12/schema
type: object
required:
  - "@context"
  - type
  - credentialSchema
  - validTo
  - issuer
  - credentialSubject
description: A purchase order is a commercial document issued by a buyer to a seller, indicating types, quantities, and agreed prices for products or services.
properties:
  "@context":
    type: string
    format: uri
    description: 'Linked Data context for semantic interoperability'
    const: "https://unvtd.unece.org/purchase-order-context.json"
  type:
    type: array
    description: 'Document types'
    items:
      type: string
      enum:
        - VerifiableCredential
        - PurchaseOrder
    minItems: 2
    maxItems: 2
    example:
      - VerifiableCredential
      - PurchaseOrder
  credentialSchema:
    type: object
    description: 'Reference to the credential schema for validation'
    properties:
      id:
        type: string
        format: uri
        const: "https://unvtd.unece.org/purchase-order-schema.yaml"
        description: 'Public location of the schema'
      type:
        type: string
        const: "JsonSchema"
        description: 'Schema type identifier'
    required:
      - id
      - type
  id:
    type: string
    format: uri
    description: 'Unique identifier for this purchase order credential'
    example: "urn:uuid:e9bf65a3-9ff3-4988-8c44-2535b949279f"
  validFrom:
    example: 2025-03-06T10:00:00Z
    type: string
    format: date-time
    description: 'Date from which this credential is valid'
  validTo:
    example: 2026-03-06T10:00:00Z
    type: string
    format: date-time
    description: 'Date until which this credential is valid'
  issuer:
    name: 'Issuer'
    description: 'Identifier of the party that issued this purchase order credential (e.g., DID)'
    type: string
    format: uri
    example: did:web:waveridersupplies.example.com
  credentialSubject:
    name: Purchase Order
    description: 'Purchase order document details'
    type: object
    required:
      - purchaseOrderNumber
      - orderDate
      - buyer
      - seller
      - deliveryLocation
      - orderedItems
    properties:
      purchaseOrderNumber:
        example: PO-2025-001
        type: string
        description: Identifier assigned by the buyer to an order.
      orderDate:
        example: '2025-03-06T00:00:00Z'
        type: string
        format: date-time
        description: Date of order.
      buyer:
        description: Party to which merchandise or services are sold.
        type: object
        required:
          - type
          - id
          - name
        properties:
          type:
            type: string
            default: Buyer
            enum:
            - Buyer
          id:
            example: did:web:waveridersupplies.example.com
            type: string
            format: uri
            description: A unique party identifier.
          name:
            example: Wave Rider Supplies, Inc
            type: string
            description: Trade party name.
          street:
            example: 210 Ocean Road
            type: string
            description: The street component of the address
          city:
            example: Williamsburg
            type: string
            description: The city component of the address
          state:
            example: NSW
            type: string
            description: The state component of the address
          zip:
            example: 75002
            type: number
            description: The postal code
          country:
            example: AU
            type: string
            description: Country.
      seller:
        description: Party selling merchandise or services to a buyer.
        type: object
        required:
          - type
          - id
          - name
        properties:
          type:
            type: string
            default: Seller
            enum:
            - Seller
          id:
            example: did:web:surfpro.example.com
            type: string
            format: uri
            description: A unique party identifier.
          name:
            example: SurfPro Manufacturing Inc.
            type: string
            description: Trade party name.
          street:
            example: 150 Industrial Drive
            type: string
            description: The street component of the address
          city:
            example: Gold Coast
            type: string
            description: The city component of the address
          state:
            example: QLD
            type: string
            description: The state component of the address
          zip:
            example: 4217
            type: number
            description: The postal code
          country:
            example: AU
            type: string
            description: Country.
      invoicee:
        description: Party to whom an invoice is issued.
        type: object
        properties:
          type:
            type: string
            default: Invoicee
            enum:
            - Invoicee
          id:
            example: did:web:waveridersupplies.example.com
            type: string
            format: uri
            description: A unique party identifier.
          name:
            example: Wave Rider Supplies, Inc
            type: string
            description: Trade party name.
          street:
            example: 210 Ocean Road
            type: string
            description: The street component of the address
          city:
            example: Williamsburg
            type: string
            description: The city component of the address
          state:
            example: NSW
            type: string
            description: The state component of the address
          zip:
            example: 75002
            type: number
            description: The postal code
          country:
            example: AU
            type: string
            description: Country.
      deliveryLocation:
        description: Location to which a consignment is to be delivered to the final consignee.
        type: object
        required:
          - name
        properties:
          name:
            example: Wave Rider Supplies Warehouse
            type: string
            description: Name of the delivery location
          street:
            example: 210 Ocean Road
            type: string
            description: The street component of the address
          city:
            example: Williamsburg
            type: string
            description: The city component of the address
          state:
            example: NSW
            type: string
            description: The state component of the address
          zip:
            example: 75002
            type: number
            description: The postal code
          country:
            example: AU
            type: string
            description: Country
          unlocode:
            type: string
            format: uri
            description: UN/LOCODE location identifier
      paymentTerms:
        example: Net 30 days
        type: string
        description: Identification of the terms of payment between the parties to a transaction.
      paymentMethod:
        example: Wire Transfer
        type: string
        description: Code specifying a method of payment.
      allowanceCharge:
        description: Code specifying a type of an adjustment to a monetary amount such as an allowance or charge.
        type: object
        properties:
          type:
            type: string
            enum: [allowance, charge]
            description: Whether this is an allowance or charge
          description:
            type: string
            description: Description of the allowance or charge
          amount:
            type: object
            properties:
              amount:
                type: number
                format: float
                description: The monetary amount
              currency:
                type: string
                description: Currency code
      totalOrderAmount:
        description: Total amount of an order.
        type: object
        properties:
          amount:
            example: 73250.00
            type: number
            format: float
            description: Total order amount
          currency:
            example: USD
            type: string
            description: Currency code
      orderedItems:
        name: Ordered Items
        description: 'Items being ordered'
        type: array
        minItems: 1
        items:
          type: object
          required:
            - productIdentifier
            - quantityOrdered
          properties:
            productIdentifier:
              example: SURF-LB-001
              type: string
              description: Reference number identifying a product.
            product:
              type: object
              properties:
                id:
                  example: urn:uuid:surf-001-longboard
                  type: string
                  format: uri
                  description: A unique identifier for the product.
                name:
                  example: Professional Longboard - Ocean Series
                  type: string
                  description: Product name
                description:
                  example: High-performance longboard with premium bamboo core and fiberglass construction, 9'6" length
                  type: string
                  description: Product description
              description: Product details
            quantityOrdered:
              example: 25
              type: number
              description: The quantity which has been ordered.
            unitPrice:
              description: Price per unit of quantity on which an article item amount is calculated.
              type: object
              properties:
                amount:
                  example: 750.00
                  type: number
                  format: float
                  description: Unit price amount
                currency:
                  example: USD
                  type: string
                  description: Currency code
            lineTotal:
              description: Total amount for this line item.
              type: object
              properties:
                amount:
                  example: 18750.00
                  type: number
                  format: float
                  description: Line total amount
                currency:
                  example: USD
                  type: string
                  description: Currency code
          description: A line item in the purchase order specifying products or services to be purchased.
