{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/navision/json-schema/navision-purchase-order-schema.json",
  "title": "PurchaseOrder",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/navision-purchase-orders-api-openapi.yml#/components/schemas/PurchaseOrder",
  "type": "object",
  "properties": {
    "@odata.etag": {
      "type": "string"
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "The unique identifier of the purchase order"
    },
    "number": {
      "type": "string",
      "description": "The purchase order number",
      "maxLength": 20
    },
    "orderDate": {
      "type": "string",
      "format": "date",
      "description": "The order date"
    },
    "postingDate": {
      "type": "string",
      "format": "date",
      "description": "The posting date"
    },
    "vendorId": {
      "type": "string",
      "format": "uuid",
      "description": "The vendor ID"
    },
    "vendorNumber": {
      "type": "string",
      "description": "The vendor number",
      "maxLength": 20
    },
    "vendorName": {
      "type": "string",
      "description": "The vendor name",
      "maxLength": 100
    },
    "payToName": {
      "type": "string",
      "maxLength": 100
    },
    "payToVendorId": {
      "type": "string",
      "format": "uuid"
    },
    "payToVendorNumber": {
      "type": "string",
      "maxLength": 20
    },
    "shipToName": {
      "type": "string",
      "maxLength": 100
    },
    "shipToContact": {
      "type": "string",
      "maxLength": 100
    },
    "buyFromAddressLine1": {
      "type": "string",
      "maxLength": 100
    },
    "buyFromAddressLine2": {
      "type": "string",
      "maxLength": 50
    },
    "buyFromCity": {
      "type": "string",
      "maxLength": 30
    },
    "buyFromCountry": {
      "type": "string",
      "maxLength": 10
    },
    "buyFromState": {
      "type": "string",
      "maxLength": 20
    },
    "buyFromPostCode": {
      "type": "string",
      "maxLength": 20
    },
    "currencyId": {
      "type": "string",
      "format": "uuid"
    },
    "currencyCode": {
      "type": "string",
      "maxLength": 10
    },
    "pricesIncludeTax": {
      "type": "boolean"
    },
    "paymentTermsId": {
      "type": "string",
      "format": "uuid"
    },
    "shipmentMethodId": {
      "type": "string",
      "format": "uuid"
    },
    "purchaser": {
      "type": "string",
      "maxLength": 20
    },
    "requestedReceiptDate": {
      "type": "string",
      "format": "date"
    },
    "discountAmount": {
      "type": "number",
      "format": "decimal"
    },
    "discountAppliedBeforeTax": {
      "type": "boolean"
    },
    "totalAmountExcludingTax": {
      "type": "number",
      "format": "decimal",
      "readOnly": true
    },
    "totalTaxAmount": {
      "type": "number",
      "format": "decimal",
      "readOnly": true
    },
    "totalAmountIncludingTax": {
      "type": "number",
      "format": "decimal",
      "readOnly": true
    },
    "fullyReceived": {
      "type": "boolean",
      "readOnly": true
    },
    "status": {
      "type": "string",
      "enum": [
        "Draft",
        "In Review",
        "Open",
        "Released"
      ],
      "readOnly": true
    },
    "lastModifiedDateTime": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "purchaseOrderLines": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PurchaseOrderLine"
      }
    }
  },
  "$defs": {
    "PurchaseOrderLine": {
      "type": "object",
      "properties": {
        "@odata.etag": {
          "type": "string"
        },
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "documentId": {
          "type": "string",
          "format": "uuid"
        },
        "sequence": {
          "type": "integer"
        },
        "itemId": {
          "type": "string",
          "format": "uuid"
        },
        "accountId": {
          "type": "string",
          "format": "uuid"
        },
        "lineType": {
          "type": "string",
          "enum": [
            "Comment",
            "Account",
            "Item",
            "Fixed Asset",
            "Charge"
          ]
        },
        "lineObjectNumber": {
          "type": "string",
          "maxLength": 20
        },
        "description": {
          "type": "string",
          "maxLength": 100
        },
        "description2": {
          "type": "string",
          "maxLength": 50
        },
        "unitOfMeasureId": {
          "type": "string",
          "format": "uuid"
        },
        "unitOfMeasureCode": {
          "type": "string",
          "maxLength": 10
        },
        "quantity": {
          "type": "number",
          "format": "decimal"
        },
        "directUnitCost": {
          "type": "number",
          "format": "decimal"
        },
        "discountAmount": {
          "type": "number",
          "format": "decimal"
        },
        "discountPercent": {
          "type": "number",
          "format": "decimal"
        },
        "discountAppliedBeforeTax": {
          "type": "boolean"
        },
        "amountExcludingTax": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "taxCode": {
          "type": "string",
          "maxLength": 20
        },
        "taxPercent": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "totalTaxAmount": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "amountIncludingTax": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "expectedReceiptDate": {
          "type": "string",
          "format": "date"
        },
        "receivedQuantity": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "invoicedQuantity": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "invoiceQuantity": {
          "type": "number",
          "format": "decimal"
        },
        "receiveQuantity": {
          "type": "number",
          "format": "decimal"
        }
      }
    }
  }
}