{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Documento Contable de Liquidación Electrónica",
    "type": "object",
    "properties": {
        "identificacion": {
            "description": "Identificación",
            "type": "object",
            "properties": {
                "version": {
                    "type": "integer",
                    "description": "Versión",
                    "const": 2
                },
                "ambiente": {
                    "type": "string",
                    "description": "Ambiente de destino",
                    "enum": [
                        "00",
                        "01"
                    ]
                },
                "tipoDte": {
                    "type": "string",
                    "description": "Tipo de Documento",
                    "const": "09"
                },
                "numeroControl": {
                    "type": "string",
                    "description": "Número de Control",
                    "maxLength": 31,
                    "minLength": 31,
                    "pattern": "^(?!.*[\r\n])DTE-09-(M|B|S|P)([0-9]{3})(P)([0-9]{3})-[0-9]{15}"
                },
                "codigoGeneracion": {
                    "type": "string",
                    "description": "Código de Generación",
                    "maxLength": 36,
                    "minLength": 36,
                    "pattern": "^(?!.*[\r\n])[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$"
                },
                "tipoModelo": {
                    "type": "number",
                    "description": "Modelo de Facturación",
                    "const": 1
                },
                "tipoOperacion": {
                    "type": "integer",
                    "description": "Tipo de Transmisión",
                    "const": 1
                },
                "fecEmi": {
                    "type": "string",
                    "description": "Fecha de Generación",
                    "format": "date"
                },
                "horEmi": {
                    "type": "string",
                    "description": "Hora de Generación",
                    "pattern": "^(?!.*[\r\n])(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]?$"
                },
                "tipoMoneda": {
                    "type": "string",
                    "description": "Tipo de Moneda",
                    "enum": [
                        "USD"
                    ]
                }
            },
            "additionalProperties": false,
            "required": [
                "version",
                "ambiente",
                "tipoDte",
                "numeroControl",
                "codigoGeneracion",
                "tipoModelo",
                "tipoOperacion",
                "fecEmi",
                "horEmi",
                "tipoMoneda"
            ]
        },
        "emisor": {
            "type": "object",
            "description": "Emisor",
            "properties": {
                "nit": {
                    "description": "NIT (Emisor)",
                    "type": "string"
                },
                "nrc": {
                    "description": "NRC (Emisor)",
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 8
                },
                "nombre": {
                    "type": "string",
                    "description": "Nombre (Emisor)",
                    "maxLength": 250,
                    "minLength": 1
                },
                "codActividad": {
                    "type": "string",
                    "description": "Código de Actividad Económica (Emisor)",
                    "maxLength": 6,
                    "minLength": 5
                },
                "descActividad": {
                    "type": "string",
                    "description": "Actividad Económica (Emisor)",
                    "maxLength": 150,
                    "minLength": 5
                },
                "nombreComercial": {
                    "description": "Nombre Comercial (Emisor)",
                    "type": [
                        "string",
                        "null"
                    ],
                    "maxLength": 150,
                    "minLength": 1
                },
                "telefono": {
                    "type": "string",
                    "description": "Teléfono (Emisor)",
                    "minLength": 8,
                    "maxLength": 30
                },
                "correo": {
                    "type": "string",
                    "description": "Correo electrónico (Emisor)",
                    "maxLength": 100,
                    "minLength": 6
                },
                "direccion": {
                    "type": "object",
                    "description": "Dirección (Emisor)",
                    "properties": {
                        "departamento": {
                            "type": "string",
                            "description": "Dirección Departamento (Emisor)"
                        },
                        "municipio": {
                            "type": "string",
                            "description": "Dirección Municipio (Emisor)"
                        },
                        "distrito": {
                            "type": "string",
                            "description": "Dirección Distrito (Emisor)"
                        },
                        "complemento": {
                            "type": "string",
                            "description": "Dirección complemento (Emisor)",
                            "maxLength": 200,
                            "minLength": 1
                        }
                    },
                    "additionalProperties": false,
                    "required": [
                        "departamento",
                        "municipio",
                        "distrito",
                        "complemento"
                    ]
                },
                "codEstable": {
                    "description": "Codigo del establecimiento asignado por el contribuyente ",
                    "type": [
                        "string",
                        "null"
                    ],
                    "maxLength": 4,
                    "minLength": 4
                },
                "codPuntoVenta": {
                    "description": "Codigo del punto de venta:(Emisor) asignado por el contribuyente",
                    "type": [
                        "string",
                        "null"
                    ],
                    "maxLength": 15,
                    "minLength": 1
                }
            },
            "additionalProperties": false,
            "required": [
                "nit",
                "nrc",
                "nombre",
                "codActividad",
                "descActividad",
                "nombreComercial",
                "telefono",
                "correo",
                "direccion",
                "codEstable",
                "codPuntoVenta"
            ]
        },
        "receptor": {
            "type": "object",
            "description": "Receptor",
            "properties": {
                "nit": {
                    "type": "string",
                    "description": "NIT (Receptor)"
                },
                "nrc": {
                    "type": [
                        "string",
                        "null"
                    ],
                    "description": "NRC (Receptor)"
                },
                "nombre": {
                    "type": "string",
                    "description": "Nombre (Receptor)",
                    "maxLength": 250,
                    "minLength": 1
                },
                "codActividad": {
                    "type": "string",
                    "description": "Código de Actividad Económica (Receptor)",
                    "minLength": 5,
                    "maxLength": 6
                },
                "descActividad": {
                    "type": "string",
                    "description": "Act. Económica (Receptor)",
                    "maxLength": 150,
                    "minLength": 5
                },
                "nombreComercial": {
                    "description": "Nombre Comercial (Receptor)",
                    "type": [
                        "string",
                        "null"
                    ],
                    "maxLength": 150,
                    "minLength": 1
                },
                "tipoEstablecimiento": {
                    "type": "string",
                    "description": "Tipo de establecimiento (Receptor)"
                },
                "direccion": {
                    "type": [
                        "object",
                        "null"
                    ],
                    "description": "Dirección (Emisor)",
                    "properties": {
                        "departamento": {
                            "type": "string",
                            "description": "Dirección: Departamento (Receptor)"
                        },
                        "municipio": {
                            "type": "string",
                            "description": "Dirección: Municipio (Receptor)"
                        },
                        "distrito": {
                            "type": "string",
                            "description": "Dirección Distrito (Emisor)"
                        },
                        "complemento": {
                            "type": "string",
                            "description": "Dirección: complemento (Receptor)",
                            "maxLength": 200,
                            "minLength": 1
                        }
                    },
                    "additionalProperties": false,
                    "required": [
                        "departamento",
                        "municipio",
                        "distrito",
                        "complemento"
                    ]
                },
                "telefono": {
                    "type": [
                        "string",
                        "null"
                    ],
                    "description": "Teléfono (Receptor)",
                    "minLength": 8,
                    "maxLength": 30
                },
                "correo": {
                    "type": "string",
                    "description": "Correo electrónico (Receptor)",
                    "minLength": 6,
                    "maxLength": 100
                }
            },
            "additionalProperties": false,
            "required": [
                "nit",
                "nrc",
                "nombre",
                "telefono",
                "correo",
                "direccion",
                "tipoEstablecimiento",
                "codActividad",
                "descActividad",
                "nombreComercial"
            ]
        },
        "cuerpoDocumento": {
            "type": "object",
            "description": "Cuerpo del Documento",
            "properties": {
                "periodoLiquidacionFechaInicio": {
                    "type": "string",
                    "format": "date",
                    "description": "Fecha inicio del período de Liquidación"
                },
                "periodoLiquidacionFechaFin": {
                    "type": "string",
                    "format": "date",
                    "description": "Fecha fin del período de Liquidación"
                },
                "codLiquidacion": {
                    "type": [
                        "string",
                        "null"
                    ],
                    "description": "Código de Liquidación",
                    "maxLength": 30,
                    "minLength": 1
                },
                "cantidadDoc": {
                    "type": [
                        "number",
                        "null"
                    ],
                    "description": "Cantidad de Documentos",
                    "exclusiveMinimum": 0,
                    "exclusiveMaximum": 1000000000
                },
                "valorOperaciones": {
                    "type": "number",
                    "description": "Valor de las Operaciones a Liquidar",
                    "exclusiveMinimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "montoSinPercepcion": {
                    "type": [
                        "number",
                        "null"
                    ],
                    "description": "Valores no sujetos a percepción",
                    "minimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "descripSinPercepcion": {
                    "description": "Descripción del valor no sujeto a percepción",
                    "type": [
                        "string",
                        "null"
                    ],
                    "minLength": 1,
                    "maxLength": 100
                },
                "subTotal": {
                    "type": "number",
                    "description": "Sub-Total",
                    "exclusiveMinimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "iva": {
                    "type": "number",
                    "description": "IVA de las Operaciones a liquidar",
                    "exclusiveMinimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "montoSujetoPercepcion": {
                    "type": "number",
                    "description": "Monto sujeto a percepción sin IVA",
                    "exclusiveMinimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "ivaPercibido": {
                    "type": "number",
                    "description": "IVA Percibido (2%)",
                    "exclusiveMinimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "comision": {
                    "type": "number",
                    "description": "Comisión",
                    "minimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "porcentComision": {
                    "description": "Porcentaje de Comisión",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100,
                    "multipleOf": 0.01
                },
                "ivaComision": {
                    "type": "number",
                    "description": "IVA de la Comisión",
                    "minimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "liquidoApagar": {
                    "type": "number",
                    "description": "Valor líquido a pagar al afiliado",
                    "exclusiveMinimum": 0,
                    "exclusiveMaximum": 100000000000,
                    "multipleOf": 0.01
                },
                "totalLetras": {
                    "description": "Valor en Letras",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                },
                "observaciones": {
                    "description": "Observaciones por ítems",
                    "type": [
                        "string",
                        "null"
                    ],
                    "minLength": 1,
                    "maxLength": 1000
                }
            },
            "additionalProperties": false,
            "required": [
                "periodoLiquidacionFechaInicio",
                "periodoLiquidacionFechaFin",
                "valorOperaciones",
                "subTotal",
                "iva",
                "montoSujetoPercepcion",
                "ivaPercibido",
                "comision",
                "porcentComision",
                "ivaComision",
                "liquidoApagar",
                "codLiquidacion",
                "cantidadDoc",
                "montoSinPercepcion",
                "descripSinPercepcion",
                "totalLetras",
                "observaciones"
            ]
        },
        "extension": {
            "type": "object",
            "description": "Extensión",
            "properties": {
                "nombEntrega": {
                    "description": "Nombre del responsable que Genera el DTE",
                    "type": "string",
                    "maxLength": 100,
                    "minLength": 1
                },
                "docuEntrega": {
                    "description": "Documento de identificación de quien genera el DTE",
                    "type": "string",
                    "maxLength": 25,
                    "minLength": 1
                },
                "codEmpleado": {
                    "description": "Código de empleado responsable de la liquidación",
                    "type": [
                        "string",
                        "null"
                    ],
                    "maxLength": 15,
                    "minLength": 1
                }
            },
            "additionalProperties": false,
            "required": [
                "nombEntrega",
                "docuEntrega",
                "codEmpleado"
            ]
        },
        "apendice": {
            "description": "Apéndice",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object",
                "properties": {
                    "campo": {
                        "type": "string",
                        "description": "Nombre del campo",
                        "maxLength": 25,
                        "minLength": 2
                    },
                    "etiqueta": {
                        "type": "string",
                        "description": "Descripción",
                        "maxLength": 50,
                        "minLength": 3
                    },
                    "valor": {
                        "type": "string",
                        "description": "Valor/Dato",
                        "maxLength": 150,
                        "minLength": 1
                    }
                },
                "additionalProperties": false,
                "required": [
                    "campo",
                    "etiqueta",
                    "valor"
                ]
            },
            "minItems": 1,
            "maxItems": 10
        }
    },
    "additionalProperties": false,
    "required": [
        "identificacion",
        "emisor",
        "receptor",
        "cuerpoDocumento",
        "extension",
        "apendice"
    ]
}