{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vetdatastandards.com/schemas/v0.1/invoice-line.schema.json",
  "title": "Invoice line",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "invoiceId",
    "description",
    "quantity",
    "unitPrice",
    "priceIncludesTax",
    "lineTotal",
    "source"
  ],
  "properties": {
    "id": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/id" },
    "source": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/source" },
    "matchKeys": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/matchKeys" },
    "createdAt": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/dateTime" },
    "updatedAt": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/dateTime" },
    "deletedAt": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/dateTime" },
    "active": { "type": "boolean" },
    "extensions": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/extensions" },
    "invoiceId": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/id" },
    "patientId": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/id" },
    "productId": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/id" },
    "serviceId": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/id" },
    "description": { "type": "string", "minLength": 1, "maxLength": 512 },
    "quantity": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/decimal" },
    "unitPrice": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/decimal" },
    "priceIncludesTax": { "type": "boolean" },
    "lineTotal": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/decimal" },
    "kind": {
      "type": "string",
      "enum": ["product", "service", "other"]
    },
    "kindRaw": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/rawText" },
    "taxPercent": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/taxPercent" },
    "netAmount": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/decimal" },
    "taxAmount": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/decimal" }
  },
  "if": {
    "properties": { "kind": { "const": "other" } },
    "required": ["kind"]
  },
  "then": {
    "required": ["kindRaw"]
  }
}
