{
  "openapi": "3.0.1",
  "info": {
    "title": "Krats Tracking API",
    "description": "Contrato de las APIs JSON de pedidos. La guia de uso esta en /documentacion/apis.",
    "version": "v1"
  },
  "paths": {
    "/api/pedidos": {
      "post": {
        "tags": [
          "Seguimiento"
        ],
        "summary": "Registrar pedido",
        "description": "Alta interna. No aplica las reglas de duplicado ni de anexo de POST /api/pedidos/nuevo. Si Detalles llega vacio, guarda una linea de relleno. HTTP 201 y datos es el PedidoId nuevo.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegistrarPedidoDto"
              },
              "example": {
                "EmpresaId": 1,
                "SucursalId": 1,
                "NumeroPedidoExterno": "PED-INT-100",
                "IdentificacionCliente": "1010101010",
                "NombreCliente": "Maria Lopez",
                "DireccionEntrega": "Calle 10 # 32-45"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RegistrarPedidoDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RegistrarPedidoDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoOperacionInt32"
                },
                "example": {
                  "exitoso": true,
                  "mensaje": "Pedido registrado correctamente.",
                  "mostrarComoModal": false,
                  "datos": 1204
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoOperacionInt32"
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/{pedidoId}": {
      "get": {
        "tags": [
          "Seguimiento"
        ],
        "summary": "Ver pedido, estado actual e historial",
        "description": "Tracking por PedidoId interno, no por numero externo. datos.pedido.estadoPedidoId es el estado actual. datos.historial recorre los estados anteriores, del mas reciente al mas antiguo, con observacion, responsable y fecha.",
        "parameters": [
          {
            "name": "pedidoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "empresaId",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoOperacionDetallePedidoVistaModelo"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoOperacionDetallePedidoVistaModelo"
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/{pedidoId}/estado": {
      "post": {
        "tags": [
          "Seguimiento"
        ],
        "summary": "Cambiar estado del pedido",
        "description": "Escribe un movimiento en el historial. El PedidoId de la ruta reemplaza al del cuerpo. Los estados 5 y 6 exigen MensajeroId. Sin la cookie de Coordinador o Administrativo hay redireccion a /cuenta/login, no un JSON.",
        "parameters": [
          {
            "name": "pedidoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CambiarEstadoPedidoDto"
              },
              "example": {
                "EmpresaId": 1,
                "EstadoPedidoId": 6,
                "MensajeroId": "mensajero-01",
                "Observacion": "Sale a ruta norte"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CambiarEstadoPedidoDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CambiarEstadoPedidoDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoOperacion"
                },
                "example": {
                  "exitoso": true,
                  "mensaje": "Estado actualizado correctamente.",
                  "mostrarComoModal": false
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoOperacion"
                }
              }
            }
          }
        },
        "security": [
          {
            "cookieAuth": [ ]
          }
        ]
      }
    },
    "/api/pedidos/por-externo": {
      "get": {
        "tags": [
          "Integracion externa"
        ],
        "summary": "Consultar estado por numero externo",
        "description": "Busca el pedido mas reciente de la empresa por NumeroPedidoExterno (por ejemplo App-5203). No exige sucursal ni PedidoId interno. Si no existe o los parametros vienen vacios, responde HTTP 200 con data null. No recorre el historial.",
        "parameters": [
          {
            "name": "empresaId",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "numeroPedidoExterno",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                },
                "example": {
                  "status": "200",
                  "data": {
                    "pedidoId": 1204,
                    "numeroPedidoExterno": "App-5203",
                    "estadoPedidoId": 4,
                    "estado": "En caja",
                    "mensajeroNombre": "",
                    "fechaPedido": "2026-05-12T14:30:00",
                    "fechaEntrega": null
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/nuevo": {
      "post": {
        "tags": [
          "Integracion externa"
        ],
        "summary": "Recibir pedido nuevo",
        "description": "Crea un pedido en estado Nuevo (1). No duplica EmpresaId + SucursalId + NumeroPedidoExterno. Si el cliente tiene un pedido en estado 1, 2 o 3 de la ultima hora, los productos se anexan a ese pedido. EmpresaId debe ser 1. HTTP 200 tambien significa que el pedido ya existia: leer data.mensaje. El campo Anexo no se usa.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecibirPedidoNuevoExternoDto"
              },
              "example": {
                "EmpresaId": 1,
                "SucursalId": 1,
                "NumeroPedidoExterno": "PED-EXT-2026-001",
                "IdentificacionCliente": "1010101010",
                "NombreCliente": "Maria Lopez",
                "TelefonoCliente": "3001234567",
                "Ciudad": "Medellin",
                "DireccionEntrega": "Calle 10 # 32-45",
                "Vendedor": "Canal Web",
                "MedioPago": "Transferencia",
                "DetallePedido": [
                  {
                    "Descripcion": "Cafe molido 500g",
                    "Ubicacion": "Pasillo 3",
                    "Cantidad": 2
                  }
                ]
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RecibirPedidoNuevoExternoDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RecibirPedidoNuevoExternoDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                },
                "example": {
                  "status": "200",
                  "data": {
                    "mensaje": "Se ha guardado exitosamente"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/listo-para-asignar": {
      "post": {
        "tags": [
          "Integracion externa"
        ],
        "summary": "Recibir pedido listo para asignar",
        "description": "Registra o actualiza un pedido en estado 5. No duplica EmpresaId + SucursalId + NumeroFactura + CodigoCaja. Si el cliente tiene un pedido activo en estado 1, 2, 3 o 4, lo actualiza y conserva su numero externo. Un alta nueva usa NumeroPedidoExterno = NumeroFactura-CodigoCaja. EmpresaId debe ser 1. ValorPedido no puede ser negativo.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecibirPedidoListoAsignarExternoDto"
              },
              "example": {
                "EmpresaId": 1,
                "SucursalId": 1,
                "IdentificacionCliente": "1010101010",
                "MedioPago": "Efectivo",
                "ValorPedido": 12000,
                "CajeroUsuarioId": "103",
                "NumeroFactura": "FE-2026-5588",
                "CodigoCaja": "CJ-01"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RecibirPedidoListoAsignarExternoDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RecibirPedidoListoAsignarExternoDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                },
                "example": {
                  "status": "200",
                  "data": {
                    "mensaje": "El pedido fue guardado como listo para asignar"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/pedidos-facturados": {
      "post": {
        "tags": [
          "Integracion externa"
        ],
        "summary": "Listar pedidos facturados",
        "description": "Devuelve pedidos no pagados en punto de venta cuyo estado no es 1, 2, 3, 4, 8 ni 9. SucursalId se recibe y no filtra. La respuesta no trae estado ni historial. Efectivo, Tarjeta, Transferencia, Qr y Anulacion salen como texto.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoPedidosFacturados"
              },
              "example": {
                "EmpresaId": 1,
                "CajeroUsuarioId": "103",
                "FechaFactura": "2026-05-12"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoPedidosFacturados"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoPedidosFacturados"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DtoPedidoFacturadoRespuesta"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/estado-pedidos-facturados": {
      "post": {
        "tags": [
          "Integracion externa"
        ],
        "summary": "Consultar pedidos facturados por numero externo",
        "description": "Recibe EmpresaId y una lista NumeroPedidoExterno. No devuelve el estado ni el historial. La vista consultada no tiene la columna NumeroPedidoExterno, asi que una lista no vacia puede responder HTTP 500. Una lista vacia responde []. Para tracking use GET /api/pedidos/{pedidoId}.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoEstadoPedidosFacturados"
              },
              "example": {
                "EmpresaId": 1,
                "NumeroPedidoExterno": [
                  "PED-EXT-2026-001"
                ]
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoEstadoPedidosFacturados"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoEstadoPedidosFacturados"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DtoPedidoFacturadoRespuesta"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/estados-pedido": {
      "post": {
        "tags": [
          "Integracion externa"
        ],
        "summary": "Consultar estados de pedido",
        "description": "Alias de POST /api/pedidos/estado-pedidos-facturados. Mismo cuerpo, mismo arreglo y la misma limitacion: no recorre el historial.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoEstadoPedidosFacturados"
              },
              "example": {
                "EmpresaId": 1,
                "NumeroPedidoExterno": [
                  "PED-EXT-2026-001"
                ]
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoEstadoPedidosFacturados"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RequerimientoEstadoPedidosFacturados"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DtoPedidoFacturadoRespuesta"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/estado-por-telefono": {
      "post": {
        "tags": [
          "Integracion externa"
        ],
        "summary": "Consultar estado del pedido por telefono",
        "description": "Devuelve el pedido en curso del cliente (distinto de Entregado, Eliminado y Cancelado), el estado, la hora en que entro a ese estado y si aun acepta anexo. El anexo solo es posible en Nuevo, En preparacion y En espera. Telefono acepta 3001234567 o 573001234567. EmpresaId vacio o menor que 1 se toma como 1.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConsultaEstadoPedidoTelefonoDto"
              },
              "example": {
                "EmpresaId": 1,
                "Telefono": "3001234567"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ConsultaEstadoPedidoTelefonoDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ConsultaEstadoPedidoTelefonoDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                },
                "example": {
                  "status": "200",
                  "data": {
                    "encontrado": true,
                    "numeroPedido": "PED-EXT-2026-001",
                    "nombreCliente": "Maria Lopez",
                    "estadoId": 2,
                    "estado": "En preparacion",
                    "horaEstado": "20:15",
                    "permiteAnexo": true,
                    "mensaje": "El cliente si puede agregar productos a este pedido."
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                }
              }
            }
          }
        }
      }
    },
    "/api/pedidos/promedio-entrega": {
      "get": {
        "tags": [
          "Integracion externa"
        ],
        "summary": "Promedio de entrega para informar",
        "description": "Promedio en minutos de los pedidos entregados en los ultimos 60 minutos, menos 15. Si el resultado queda por debajo de 20, responde 20. Sin entregas en esa hora, disponible es false. empresaId vacio o menor que 1 se toma como 1. sucursalId vacio toma toda la empresa.",
        "parameters": [
          {
            "name": "empresaId",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "sucursalId",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRespuestaJson"
                },
                "example": {
                  "status": "200",
                  "data": {
                    "disponible": true,
                    "minutos": 25,
                    "pedidosConsiderados": 12
                  }
                }
              }
            }
          }
        }
      }
    },
    "/consulta/datos": {
      "get": {
        "tags": [
          "Consulta"
        ],
        "summary": "Tablero de pedidos en curso",
        "description": "Cada pedido trae su estado actual, color y responsable. No trae los estados anteriores. sucursalId es opcional. La empresa sale de la cookie del rol Consulta.",
        "parameters": [
          {
            "name": "sucursalId",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsultaTableroVistaModelo"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "cookieAuth": [ ]
          }
        ]
      }
    },
    "/consulta/pedido/{pedidoId}": {
      "get": {
        "tags": [
          "Consulta"
        ],
        "summary": "Estado actual de un pedido",
        "description": "Devuelve el estado vigente, quien lo tiene a cargo y el estado de cada producto: Pendiente, Recogido o Agotado. No devuelve el historial. Para la linea de tiempo use GET /api/pedidos/{pedidoId}.",
        "parameters": [
          {
            "name": "pedidoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsultaPedidoDetalleVistaModelo"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "cookieAuth": [ ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ApiRespuestaJson": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CambiarEstadoPedidoDto": {
        "type": "object",
        "properties": {
          "pedidoId": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "format": "int32"
          },
          "empresaId": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "format": "int32"
          },
          "estadoPedidoId": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "format": "int32"
          },
          "usuarioId": {
            "type": "string",
            "nullable": true
          },
          "mensajeroId": {
            "type": "string",
            "nullable": true
          },
          "observacion": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ConsultaEstadoPedidoTelefonoDto": {
        "type": "object",
        "properties": {
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "telefono": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ConsultaItemPedidoVistaModelo": {
        "type": "object",
        "properties": {
          "descripcion": {
            "type": "string",
            "nullable": true
          },
          "ubicacion": {
            "type": "string",
            "nullable": true
          },
          "cantidad": {
            "type": "integer",
            "format": "int32"
          },
          "estado": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ConsultaPedidoDetalleVistaModelo": {
        "type": "object",
        "properties": {
          "pedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "estadoPedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "estado": {
            "type": "string",
            "nullable": true
          },
          "colorEstado": {
            "type": "string",
            "nullable": true
          },
          "fechaPedido": {
            "type": "string",
            "format": "date-time"
          },
          "inicioEstadoActual": {
            "type": "string",
            "format": "date-time"
          },
          "direccionEntrega": {
            "type": "string",
            "nullable": true
          },
          "vendedor": {
            "type": "string",
            "nullable": true
          },
          "pickerNombre": {
            "type": "string",
            "nullable": true
          },
          "cajeroNombre": {
            "type": "string",
            "nullable": true
          },
          "mensajero": {
            "type": "string",
            "nullable": true
          },
          "motivoActual": {
            "type": "string",
            "nullable": true
          },
          "medioPago": {
            "type": "string",
            "nullable": true
          },
          "estadoTransferenciaAntes": {
            "type": "string",
            "nullable": true
          },
          "pausadoAsignacion": {
            "type": "boolean"
          },
          "liquidado": {
            "type": "boolean"
          },
          "numeroPedidoExterno": {
            "type": "string",
            "nullable": true
          },
          "numeroFactura": {
            "type": "string",
            "nullable": true
          },
          "valorPedido": {
            "type": "number",
            "format": "double"
          },
          "telefonoCliente": {
            "type": "string",
            "nullable": true
          },
          "responsable": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConsultaItemPedidoVistaModelo"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ConsultaPedidoVistaModelo": {
        "type": "object",
        "properties": {
          "pedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "estadoPedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "estado": {
            "type": "string",
            "nullable": true
          },
          "colorEstado": {
            "type": "string",
            "nullable": true
          },
          "fechaPedido": {
            "type": "string",
            "format": "date-time"
          },
          "inicioEstadoActual": {
            "type": "string",
            "format": "date-time"
          },
          "direccionEntrega": {
            "type": "string",
            "nullable": true
          },
          "vendedor": {
            "type": "string",
            "nullable": true
          },
          "pickerNombre": {
            "type": "string",
            "nullable": true
          },
          "cajeroNombre": {
            "type": "string",
            "nullable": true
          },
          "mensajero": {
            "type": "string",
            "nullable": true
          },
          "motivoActual": {
            "type": "string",
            "nullable": true
          },
          "medioPago": {
            "type": "string",
            "nullable": true
          },
          "estadoTransferenciaAntes": {
            "type": "string",
            "nullable": true
          },
          "pausadoAsignacion": {
            "type": "boolean"
          },
          "liquidado": {
            "type": "boolean"
          },
          "numeroPedidoExterno": {
            "type": "string",
            "nullable": true
          },
          "numeroFactura": {
            "type": "string",
            "nullable": true
          },
          "valorPedido": {
            "type": "number",
            "format": "double"
          },
          "telefonoCliente": {
            "type": "string",
            "nullable": true
          },
          "responsable": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "ConsultaTableroVistaModelo": {
        "type": "object",
        "properties": {
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "sucursalIdSeleccionada": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "sucursales": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Sucursal"
            },
            "nullable": true
          },
          "fechaActualizacion": {
            "type": "string",
            "format": "date-time"
          },
          "pedidos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConsultaPedidoVistaModelo"
            },
            "nullable": true
          },
          "promedioEntregaMinutosUltimos60": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "pedidosEntregadosUltimos60": {
            "type": "integer",
            "format": "int32"
          },
          "pickersActivos": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "mensajerosActivos": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "firma": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "DetallePedido": {
        "type": "object",
        "properties": {
          "detallePedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "pedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "descripcion": {
            "type": "string",
            "nullable": true
          },
          "ubicacion": {
            "type": "string",
            "nullable": true
          },
          "cantidad": {
            "type": "integer",
            "format": "int32"
          },
          "seleccionado": {
            "type": "boolean"
          },
          "agotado": {
            "type": "boolean"
          },
          "esAnexo": {
            "type": "boolean"
          },
          "solicitudAreaId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "areaSolicitud": {
            "type": "string",
            "nullable": true
          },
          "estadoSolicitudArea": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DetallePedidoExternoDto": {
        "type": "object",
        "properties": {
          "descripcion": {
            "type": "string",
            "nullable": true
          },
          "ubicacion": {
            "type": "string",
            "nullable": true
          },
          "esAnexo": {
            "type": "boolean"
          },
          "cantidad": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "DetallePedidoVistaModelo": {
        "type": "object",
        "properties": {
          "pedido": {
            "$ref": "#/components/schemas/Pedido"
          },
          "detalles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetallePedido"
            },
            "nullable": true
          },
          "historial": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistorialPedido"
            },
            "nullable": true
          },
          "estados": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EstadoPedido"
            },
            "nullable": true
          },
          "mensajeros": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Mensajero"
            },
            "nullable": true
          },
          "cambioEstado": {
            "$ref": "#/components/schemas/CambiarEstadoPedidoDto"
          },
          "pedidosEnCola": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "DtoPedidoFacturadoRespuesta": {
        "type": "object",
        "properties": {
          "fechaFactura": {
            "type": "string",
            "format": "date-time"
          },
          "numeroFactura": {
            "type": "string",
            "nullable": true
          },
          "direccionEntrega": {
            "type": "string",
            "nullable": true
          },
          "nombreCliente": {
            "type": "string",
            "nullable": true
          },
          "telefonoCliente": {
            "type": "string",
            "nullable": true
          },
          "valorPedido": {
            "type": "number",
            "format": "double"
          },
          "medioPago": {
            "type": "string",
            "nullable": true
          },
          "efectivo": {
            "type": "string",
            "nullable": true
          },
          "tarjeta": {
            "type": "string",
            "nullable": true
          },
          "transferencia": {
            "type": "string",
            "nullable": true
          },
          "qr": {
            "type": "string",
            "nullable": true
          },
          "anulacion": {
            "type": "string",
            "nullable": true
          },
          "cajeroUsuarioId": {
            "type": "string",
            "nullable": true
          },
          "liquidado": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "EstadoPedido": {
        "type": "object",
        "properties": {
          "estadoPedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "nombre": {
            "type": "string",
            "nullable": true
          },
          "color": {
            "type": "string",
            "nullable": true
          },
          "orden": {
            "type": "integer",
            "format": "int32"
          },
          "esFinal": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "HistorialPedido": {
        "type": "object",
        "properties": {
          "historialPedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "pedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "estadoPedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "estado": {
            "type": "string",
            "nullable": true
          },
          "observacion": {
            "type": "string",
            "nullable": true
          },
          "usuarioResponsable": {
            "type": "string",
            "nullable": true
          },
          "fechaRegistro": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "Mensajero": {
        "type": "object",
        "properties": {
          "mensajeroId": {
            "type": "string",
            "nullable": true
          },
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "sucursalId": {
            "type": "integer",
            "format": "int32"
          },
          "nombre": {
            "type": "string",
            "nullable": true
          },
          "documento": {
            "type": "string",
            "nullable": true
          },
          "celular": {
            "type": "string",
            "nullable": true
          },
          "activo": {
            "type": "boolean"
          },
          "disponible": {
            "type": "boolean"
          },
          "fechaRegistro": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "Pedido": {
        "type": "object",
        "properties": {
          "pedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "sucursalId": {
            "type": "integer",
            "format": "int32"
          },
          "numeroPedidoExterno": {
            "type": "string",
            "nullable": true
          },
          "identificacionCliente": {
            "type": "string",
            "nullable": true
          },
          "nombreCliente": {
            "type": "string",
            "nullable": true
          },
          "telefonoCliente": {
            "type": "string",
            "nullable": true
          },
          "ciudad": {
            "type": "string",
            "nullable": true
          },
          "direccionEntrega": {
            "type": "string",
            "nullable": true
          },
          "vendedor": {
            "type": "string",
            "nullable": true
          },
          "medioPedido": {
            "type": "string",
            "nullable": true
          },
          "medioPago": {
            "type": "string",
            "nullable": true
          },
          "valorPedido": {
            "type": "number",
            "format": "double"
          },
          "valorDomicilio": {
            "type": "number",
            "format": "double"
          },
          "estadoPedidoId": {
            "type": "integer",
            "format": "int32"
          },
          "pickerUsuarioId": {
            "type": "string",
            "nullable": true
          },
          "pickerNombre": {
            "type": "string",
            "nullable": true
          },
          "cajeroUsuarioId": {
            "type": "string",
            "nullable": true
          },
          "mensajeroId": {
            "type": "string",
            "nullable": true
          },
          "mensajeroNombre": {
            "type": "string",
            "nullable": true
          },
          "codigoCaja": {
            "type": "string",
            "nullable": true
          },
          "numeroFactura": {
            "type": "string",
            "nullable": true
          },
          "ruta": {
            "type": "string",
            "nullable": true
          },
          "canastilla": {
            "type": "string",
            "nullable": true
          },
          "observacion": {
            "type": "string",
            "nullable": true
          },
          "motivoActual": {
            "type": "string",
            "nullable": true
          },
          "estadoTransferenciaAntes": {
            "type": "string",
            "nullable": true
          },
          "pausadoAsignacion": {
            "type": "boolean"
          },
          "pagadoEnPuntoVenta": {
            "type": "boolean"
          },
          "esAnexo": {
            "type": "boolean"
          },
          "esInformativo": {
            "type": "boolean"
          },
          "liquidado": {
            "type": "boolean"
          },
          "idTipoDistancia": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "fechaPedido": {
            "type": "string",
            "format": "date-time"
          },
          "fechaFactura": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "fechaAsignacion": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "fechaEntrega": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "fechaActualizacion": {
            "type": "string",
            "format": "date-time"
          },
          "detalles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetallePedido"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RecibirPedidoListoAsignarExternoDto": {
        "type": "object",
        "properties": {
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "sucursalId": {
            "type": "integer",
            "format": "int32"
          },
          "identificacionCliente": {
            "type": "string",
            "nullable": true
          },
          "nombreCliente": {
            "type": "string",
            "nullable": true
          },
          "telefonoCliente": {
            "type": "string",
            "nullable": true
          },
          "ciudad": {
            "type": "string",
            "nullable": true
          },
          "direccionEntrega": {
            "type": "string",
            "nullable": true
          },
          "medioPago": {
            "type": "string",
            "nullable": true
          },
          "valorDomicilio": {
            "type": "number",
            "format": "double"
          },
          "valorPedido": {
            "type": "number",
            "format": "double"
          },
          "observacion": {
            "type": "string",
            "nullable": true
          },
          "cajeroUsuarioId": {
            "type": "string",
            "nullable": true
          },
          "numeroFactura": {
            "type": "string",
            "nullable": true
          },
          "codigoCaja": {
            "type": "string",
            "nullable": true
          },
          "fechaFactura": {
            "type": "string",
            "nullable": true
          },
          "pagadoEnPuntoVenta": {
            "type": "boolean"
          },
          "esAnexo": {
            "type": "boolean"
          },
          "DetallePedido": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetallePedidoExternoDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RecibirPedidoNuevoExternoDto": {
        "type": "object",
        "properties": {
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "sucursalId": {
            "type": "integer",
            "format": "int32"
          },
          "numeroPedidoExterno": {
            "type": "string",
            "nullable": true
          },
          "identificacionCliente": {
            "type": "string",
            "nullable": true
          },
          "nombreCliente": {
            "type": "string",
            "nullable": true
          },
          "telefonoCliente": {
            "type": "string",
            "nullable": true
          },
          "ciudad": {
            "type": "string",
            "nullable": true
          },
          "direccionEntrega": {
            "type": "string",
            "nullable": true
          },
          "vendedor": {
            "type": "string",
            "nullable": true
          },
          "medioPedido": {
            "type": "string",
            "nullable": true
          },
          "medioPago": {
            "type": "string",
            "nullable": true
          },
          "valorDomicilio": {
            "type": "number",
            "format": "double"
          },
          "observacion": {
            "type": "string",
            "nullable": true
          },
          "fechaPedido": {
            "type": "string",
            "nullable": true
          },
          "ruta": {
            "type": "string",
            "nullable": true
          },
          "anexo": {
            "type": "boolean"
          },
          "esInformativo": {
            "type": "boolean"
          },
          "DetallePedido": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetallePedidoExternoDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RegistrarDetallePedidoDto": {
        "required": [
          "descripcion"
        ],
        "type": "object",
        "properties": {
          "descripcion": {
            "maxLength": 250,
            "minLength": 0,
            "type": "string"
          },
          "ubicacion": {
            "maxLength": 80,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "cantidad": {
            "maximum": 999,
            "minimum": 1,
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "RegistrarPedidoDto": {
        "required": [
          "direccionEntrega",
          "identificacionCliente",
          "nombreCliente",
          "numeroPedidoExterno"
        ],
        "type": "object",
        "properties": {
          "empresaId": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "format": "int32"
          },
          "sucursalId": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "format": "int32"
          },
          "numeroPedidoExterno": {
            "maxLength": 60,
            "minLength": 0,
            "type": "string"
          },
          "identificacionCliente": {
            "maxLength": 40,
            "minLength": 0,
            "type": "string"
          },
          "nombreCliente": {
            "maxLength": 160,
            "minLength": 0,
            "type": "string"
          },
          "direccionEntrega": {
            "maxLength": 250,
            "minLength": 0,
            "type": "string"
          },
          "ciudad": {
            "maxLength": 80,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "telefonoCliente": {
            "maxLength": 40,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "vendedor": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "medioPedido": {
            "maxLength": 40,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "medioPago": {
            "maxLength": 40,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "valorPedido": {
            "type": "number",
            "format": "double"
          },
          "valorDomicilio": {
            "type": "number",
            "format": "double"
          },
          "observacion": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "detalles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RegistrarDetallePedidoDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RequerimientoEstadoPedidosFacturados": {
        "type": "object",
        "properties": {
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "numeroPedidoExterno": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RequerimientoPedidosFacturados": {
        "type": "object",
        "properties": {
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "sucursalId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "cajeroUsuarioId": {
            "type": "string",
            "nullable": true
          },
          "fechaFactura": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ResultadoOperacion": {
        "type": "object",
        "properties": {
          "exitoso": {
            "type": "boolean"
          },
          "mensaje": {
            "type": "string",
            "nullable": true
          },
          "mostrarComoModal": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ResultadoOperacionDetallePedidoVistaModelo": {
        "type": "object",
        "properties": {
          "exitoso": {
            "type": "boolean"
          },
          "mensaje": {
            "type": "string",
            "nullable": true
          },
          "mostrarComoModal": {
            "type": "boolean"
          },
          "datos": {
            "$ref": "#/components/schemas/DetallePedidoVistaModelo"
          }
        },
        "additionalProperties": false
      },
      "ResultadoOperacionInt32": {
        "type": "object",
        "properties": {
          "exitoso": {
            "type": "boolean"
          },
          "mensaje": {
            "type": "string",
            "nullable": true
          },
          "mostrarComoModal": {
            "type": "boolean"
          },
          "datos": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "Sucursal": {
        "type": "object",
        "properties": {
          "sucursalId": {
            "type": "integer",
            "format": "int32"
          },
          "empresaId": {
            "type": "integer",
            "format": "int32"
          },
          "nombre": {
            "type": "string",
            "nullable": true
          },
          "ciudad": {
            "type": "string",
            "nullable": true
          },
          "direccion": {
            "type": "string",
            "nullable": true
          },
          "activa": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "cookieAuth": {
        "type": "apiKey",
        "description": "Cookie de sesion emitida por POST /cuenta/login. Solo la exigen los endpoints marcados con el candado.",
        "name": "krats.auth",
        "in": "cookie"
      }
    }
  },
  "tags": [
    {
      "name": "Integracion externa",
      "description": "Sin sesion. POS, ecommerce o caja. Las altas responden status y data. Los listados responden un arreglo."
    },
    {
      "name": "Seguimiento",
      "description": "Estado actual e historial. Responden exitoso, mensaje y datos. Cambiar el estado exige cookie de Coordinador o Administrativo."
    },
    {
      "name": "Consulta",
      "description": "Tablero del rol Consulta. La empresa sale de la cookie. No incluyen el historial de estados."
    }
  ]
}