{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schemas.ectropy.ai/flow/vendor-price-submission.schema.json",
  "title": "Vendor Price Submission",
  "version": "0.2.0",
  "description": "A manufacturer, supplier or distributor's price offered to one customer tenant. Accepted into that tenant's price book, where it supersedes the construction reference price for that tenant only. Tagged to the manufacturer and the specific product.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "submissionId",
    "vendorRef",
    "targetTenant",
    "manufacturer",
    "product",
    "price",
    "priceUom",
    "effectiveFrom",
    "submittedAt"
  ],
  "properties": {
    "submissionId": {
      "type": "string",
      "minLength": 1
    },
    "vendorRef": {
      "$ref": "https://schemas.ectropy.ai/flow/flow-common.schema.json#/definitions/partyUri"
    },
    "targetTenant": {
      "$ref": "https://schemas.ectropy.ai/flow/flow-common.schema.json#/definitions/tenantUri"
    },
    "manufacturer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "gs1CompanyPrefix": {
          "type": "string",
          "pattern": "^[0-9]{6,12}$"
        }
      }
    },
    "product": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "gtin": {
          "type": "string",
          "pattern": "^[0-9]{8,14}$"
        },
        "manufacturerPartNumber": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "bpcProduct": {
          "type": "string"
        }
      },
      "anyOf": [
        {
          "required": [
            "gtin"
          ]
        },
        {
          "required": [
            "manufacturerPartNumber"
          ]
        }
      ]
    },
    "price": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "amount",
        "currency"
      ],
      "properties": {
        "amount": {
          "type": "number",
          "minimum": 0
        },
        "currency": {
          "$ref": "https://schemas.ectropy.ai/flow/flow-common.schema.json#/definitions/currency"
        }
      }
    },
    "priceUom": {
      "$ref": "https://schemas.ectropy.ai/flow/flow-common.schema.json#/definitions/uom"
    },
    "quantityBreaks": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "minQuantity",
          "amount"
        ],
        "properties": {
          "minQuantity": {
            "type": "number",
            "minimum": 0
          },
          "amount": {
            "type": "number",
            "minimum": 0
          }
        }
      }
    },
    "region": {
      "type": "string"
    },
    "effectiveFrom": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "expiresOn": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "leadTimeDays": {
      "type": "integer",
      "minimum": 0
    },
    "submittedAt": {
      "type": "string",
      "format": "date-time"
    }
  }
}
