{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/navision/json-schema/navision-sales-order-schema.json",
  "title": "SalesOrder",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/navision-sales-orders-api-openapi.yml#/components/schemas/SalesOrder",
  "type": "object",
  "properties": {
    "@odata.etag": {
      "type": "string"
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "The unique identifier of the sales order"
    },
    "number": {
      "type": "string",
      "description": "The sales order number",
      "maxLength": 20
    },
    "externalDocumentNumber": {
      "type": "string",
      "description": "The external document number",
      "maxLength": 35
    },
    "orderDate": {
      "type": "string",
      "format": "date",
      "description": "The order date"
    },
    "postingDate": {
      "type": "string",
      "format": "date",
      "description": "The posting date"
    },
    "customerId": {
      "type": "string",
      "format": "uuid",
      "description": "The customer ID"
    },
    "customerNumber": {
      "type": "string",
      "description": "The customer number",
      "maxLength": 20
    },
    "customerName": {
      "type": "string",
      "description": "The customer name",
      "maxLength": 100
    },
    "billToName": {
      "type": "string",
      "description": "The bill-to name",
      "maxLength": 100
    },
    "billToCustomerId": {
      "type": "string",
      "format": "uuid",
      "description": "The bill-to customer ID"
    },
    "billToCustomerNumber": {
      "type": "string",
      "description": "The bill-to customer number",
      "maxLength": 20
    },
    "shipToName": {
      "type": "string",
      "description": "The ship-to name",
      "maxLength": 100
    },
    "shipToContact": {
      "type": "string",
      "description": "The ship-to contact",
      "maxLength": 100
    },
    "sellToAddressLine1": {
      "type": "string",
      "maxLength": 100
    },
    "sellToAddressLine2": {
      "type": "string",
      "maxLength": 50
    },
    "sellToCity": {
      "type": "string",
      "maxLength": 30
    },
    "sellToCountry": {
      "type": "string",
      "maxLength": 10
    },
    "sellToState": {
      "type": "string",
      "maxLength": 20
    },
    "sellToPostCode": {
      "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"
    },
    "salesperson": {
      "type": "string",
      "maxLength": 20
    },
    "requestedDeliveryDate": {
      "type": "string",
      "format": "date"
    },
    "discountAmount": {
      "type": "number",
      "format": "decimal",
      "description": "The total discount amount"
    },
    "discountAppliedBeforeTax": {
      "type": "boolean"
    },
    "totalAmountExcludingTax": {
      "type": "number",
      "format": "decimal",
      "readOnly": true
    },
    "totalTaxAmount": {
      "type": "number",
      "format": "decimal",
      "readOnly": true
    },
    "totalAmountIncludingTax": {
      "type": "number",
      "format": "decimal",
      "readOnly": true
    },
    "fullyShipped": {
      "type": "boolean",
      "readOnly": true
    },
    "status": {
      "type": "string",
      "description": "The order status",
      "enum": [
        "Draft",
        "In Review",
        "Open",
        "Released"
      ],
      "readOnly": true
    },
    "lastModifiedDateTime": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "phoneNumber": {
      "type": "string",
      "maxLength": 30
    },
    "email": {
      "type": "string",
      "maxLength": 80
    },
    "salesOrderLines": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SalesOrderLine"
      }
    }
  },
  "$defs": {
    "SalesOrderLine": {
      "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",
            "Resource",
            "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"
        },
        "unitPrice": {
          "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
        },
        "netAmount": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "netTaxAmount": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "netAmountIncludingTax": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "shipmentDate": {
          "type": "string",
          "format": "date"
        },
        "shippedQuantity": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "invoicedQuantity": {
          "type": "number",
          "format": "decimal",
          "readOnly": true
        },
        "invoiceQuantity": {
          "type": "number",
          "format": "decimal"
        },
        "shipQuantity": {
          "type": "number",
          "format": "decimal"
        }
      }
    }
  }
}