{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://abcs.sirvisetti.com/schemas/objects/finance/journal-entry.schema.json",
  "title": "ABCS Finance Journal Entry",
  "type": "object",
  "additionalProperties": false,
  "required": ["number", "accountingDate", "currency", "lines", "status"],
  "properties": {
    "number": {"type": "string", "minLength": 1},
    "accountingDate": {"type": "string", "format": "date"},
    "currency": {"type": "string", "pattern": "^[A-Z]{3}$"},
    "description": {"type": "string"},
    "lines": {"type": "array", "minItems": 2, "items": {"type": "object", "additionalProperties": false, "required": ["lineNumber", "account", "debit", "credit"], "properties": {"lineNumber": {"type": "integer", "minimum": 1}, "account": {"type": "string", "minLength": 1}, "description": {"type": "string"}, "debit": {"$ref": "https://abcs.sirvisetti.com/schemas/common/monetary-amount.schema.json"}, "credit": {"$ref": "https://abcs.sirvisetti.com/schemas/common/monetary-amount.schema.json"}}}},
    "status": {"type": "object", "additionalProperties": false, "required": ["lifecycle"], "properties": {"lifecycle": {"type": "string", "enum": ["draft", "posted", "reversed"]}}}
  }
}
