openapi: 3.0.3 info: title: API Club de Campo La Federala (CCLF) version: 1.0.15 description: >- API del backend de CCLF: lotes, promociones, reservas, ventas, pagos, prioridades, personas, inmobiliarias, usuarios, archivos, fracciones, ubicaciones y reportes. **Autenticación.** JWT en el header `Authorization: Bearer `, obtenido con `POST /auth/login`. No se usan cookies. El acceso se evalúa con el estado vigente del usuario en cada request: un usuario eliminado, o el usuario de una inmobiliaria dada de baja (ELIMINADO), deja de operar aunque su token no haya vencido. **Autorización.** Cada operación declara en `x-roles` los roles admitidos por la ruta (`ADMINISTRADOR`, `GESTOR`, `INMOBILIARIA`, `TECNICO`). Un rol fuera de la lista recibe 403. Las reglas adicionales (tenant, campos permitidos por rol) se indican en la descripción. `INMOBILIARIA` opera solo dentro de su propia inmobiliaria. **Errores.** Formato `{ success: false, code, message }`, con `errors[]` en las validaciones. Una ruta o método inexistente responde 404 JSON `{ code: NOT_FOUND, message: "Ruta no encontrada" }`. El body JSON admite hasta 1 MB (413 `PAYLOAD_TOO_LARGE`); los archivos viajan por `multipart/form-data` con su propio límite (20 MB). **Montos.** Los campos Decimal de las entidades que se devuelven sin DTO (lotes, reservas, ofertas, promociones, ventas, plan de pago recién creado) se serializan como **string** (`"15000.5"`). El contexto de pagos, el registro de pagos, el reemplazo de plan y la comisión de inmobiliarias los devuelven como **number**. servers: - url: http://localhost:3000/api description: Desarrollo local (las rutas de la API cuelgan de /api) tags: - name: Health description: Liveness del proceso. - name: Auth description: Login con JWT Bearer. - name: Lotes - name: Promociones description: >- Promociones de precio sobre un lote. La expiración por fecha de fin la ejecuta el job programado de expiraciones (no hay endpoint manual). - name: Reservas - name: Ventas - name: Pagos description: Plan de pagos, cuotas, pagos y recargos de una venta. - name: Prioridades description: >- Prioridades sobre lotes. Al llegar `fechaFin` el job programado de expiraciones las expira con su lifecycle completo (prioridad EXPIRADA y lote restaurado si sigue CON_PRIORIDAD). - name: Personas - name: Inmobiliarias - name: Usuarios description: Administración de cuentas. - name: Files description: Documentos de lotes y ventas (BOLETO, ESCRITURA, PLANO, IMAGEN, OTRO). - name: Fracciones - name: Ubicaciones description: >- Solo lectura. Las ubicaciones se crean y modifican dentro del alta y la edición de lotes (`calle` + `numeroCalle`, o `ubicacionId`). - name: Reportes description: >- Reportes de gestión (inventario, ventas por período, cuotas vencidas), cada uno en JSON y en Excel (.xlsx). Solo ADMINISTRADOR y GESTOR: INMOBILIARIA y TECNICO reciben 403 en todas las operaciones. Las cifras se calculan en el backend con fecha de corte en America/Argentina/Buenos_Aires. Los montos viajan como string decimal con 2 cifras y ARS y USD nunca se suman ni se convierten. La query se valida antes de generar el reporte: los parámetros no declarados se ignoran y un valor inválido responde 400 `VALIDATION_ERROR` (también en las exportaciones, que en ese caso devuelven JSON y no un archivo). paths: # ============================================================ HEALTH /health: servers: - url: http://localhost:3000 description: Fuera del prefijo /api get: tags: [Health] operationId: health summary: Liveness description: >- Indica que el proceso HTTP responde. No consulta la base de datos ni otros servicios: no es un chequeo de readiness ni de dependencias. security: [] responses: '200': description: Proceso vivo headers: Cache-Control: schema: { type: string, example: no-store } content: application/json: schema: type: object required: [status] properties: status: { type: string, enum: [ok] } # ============================================================ AUTH /auth/login: post: tags: [Auth] operationId: login summary: Iniciar sesión description: >- Devuelve el usuario y un JWT. Credenciales inválidas, usuario inexistente y usuario de una inmobiliaria dada de baja (ELIMINADO) responden el mismo 401 genérico. Rate limit por cliente: 10 intentos fallidos cada 15 minutos; el siguiente responde 429. Los logins exitosos no consumen cupo. security: [] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/LoginRequest' } example: { email: usuario@example.com, password: clave-de-ejemplo } responses: '200': description: Login correcto content: application/json: schema: type: object required: [data] properties: data: { $ref: '#/components/schemas/LoginData' } '400': { $ref: '#/components/responses/BadRequest' } '401': description: Credenciales inválidas (mismo body para todos los motivos) content: application/json: schema: { $ref: '#/components/schemas/ErrorResponse' } example: { success: false, code: UNAUTHORIZED, message: Credenciales inválidas } '413': { $ref: '#/components/responses/PayloadTooLarge' } '429': { $ref: '#/components/responses/TooManyRequests' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ LOTES /lotes: get: tags: [Lotes] operationId: listarLotes summary: Listar lotes description: >- TECNICO no puede usar el filtro `deudor` (400) y su respuesta omite `deuda`, ventas y reservas. INMOBILIARIA tampoco puede usar `deudor` (400); su listado excluye los lotes NO_DISPONIBLE y omite `deuda`, ventas, reservas, `identificadorTipo`/`identificadorValor` de propietario e inquilino y el titular (`inmobiliariaId`, `ownerType`, `inmobiliaria`) de las prioridades que no son de su inmobiliaria. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA, TECNICO] security: [{ bearerAuth: [] }] parameters: - { name: estado, in: query, schema: { $ref: '#/components/schemas/EstadoLoteEntrada' } } - { name: subestado, in: query, schema: { $ref: '#/components/schemas/SubestadoLoteEntrada' } } - { name: tipo, in: query, schema: { $ref: '#/components/schemas/TipoLoteEntrada' } } - { name: ocupacion, in: query, schema: { $ref: '#/components/schemas/Ocupacion' } } - { name: propietarioId, in: query, schema: { $ref: '#/components/schemas/IdQuery' } } - { name: ubicacionId, in: query, schema: { $ref: '#/components/schemas/IdQuery' } } - name: deudor in: query description: true = solo lotes con deuda; false = sin deuda. No disponible para TECNICO ni INMOBILIARIA (400). schema: { type: string, enum: ['true', 'false'] } responses: '200': description: Lotes content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [lotes, total] properties: lotes: { type: array, items: { $ref: '#/components/schemas/Lote' } } total: { type: integer, description: Cantidad devuelta } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Lotes] operationId: crearLote summary: Crear lote description: >- La ubicación se asocia con `ubicacionId` (existente) o se crea con `calle` + `numeroCalle`; `ubicacionId` tiene prioridad. `precio` es obligatorio para "Lote Venta" y no se admite para "Espacio Comun". x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/LoteCrear' } responses: '201': description: Lote creado content: application/json: schema: { $ref: '#/components/schemas/LoteMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /lotes/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Lotes] operationId: obtenerLote summary: Obtener lote description: >- Para TECNICO la respuesta omite `deuda`, ventas y reservas. Para INMOBILIARIA omite además los documentos de propietario e inquilino, y un lote NO_DISPONIBLE responde 404, igual que uno inexistente. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA, TECNICO] security: [{ bearerAuth: [] }] responses: '200': description: Lote content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { $ref: '#/components/schemas/Lote' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } put: tags: [Lotes] operationId: actualizarLote summary: Actualizar lote description: >- Actualización parcial (al menos un campo). TECNICO solo puede modificar `subestado` y `superficie`: si envía cualquier otro campo del schema, o ninguno de esos dos, recibe 403. `calle` + `numeroCalle` actualizan la ubicación existente o crean una; `ubicacionId` conecta una existente. Pasar el lote a "No Disponible" con una venta en curso (INICIADA o CON_BOLETO, operativa) responde 409: la venta se cancela primero desde Ventas. x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/LoteActualizar' } responses: '200': description: Lote actualizado content: application/json: schema: { $ref: '#/components/schemas/LoteMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } delete: tags: [Lotes] operationId: eliminarLote summary: Eliminar lote definitivamente description: >- Borrado físico del lote, solo si no tiene historia ni asociaciones: ventas, reservas (y sus ofertas), prioridades, promociones, alquileres o archivos, en cualquier estado (incluidos los dados de baja). Si tiene alguna responde 409 y no borra nada. La ubicación del lote no bloquea (queda sin lote asignado). Solo ADMINISTRADOR. x-roles: [ADMINISTRADOR] security: [{ bearerAuth: [] }] responses: '200': description: Lote eliminado content: application/json: schema: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Lote eliminado exitosamente } data: type: object properties: message: { type: string, example: Lote eliminado correctamente } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': description: El lote tiene operaciones o asociaciones registradas; no se borró nada. content: application/json: schema: { $ref: '#/components/schemas/ConflictResponse' } example: success: false code: CONFLICT message: No se puede eliminar el lote porque tiene operaciones o asociaciones registradas (ventas, reservas, prioridades, promociones, alquileres o archivos). '500': { $ref: '#/components/responses/InternalError' } # ============================================================ PROMOCIONES /lotes/{id}/promociones/aplicar: parameters: - $ref: '#/components/parameters/Id' post: tags: [Promociones] operationId: aplicarPromocion summary: Aplicar promoción a un lote description: >- El lote debe estar DISPONIBLE, tener precio y no tener otra promoción activa. Pasa a EN_PROMOCION con el precio promocional, que debe ser menor al precio actual del lote (si es igual o mayor, 400) y tener hasta 2 decimales (si no, 400). Si otra operación cambia el estado o el precio del lote mientras se aplica (por ejemplo, otra promoción o una edición de precio en paralelo), responde 409 sin crear la promoción. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/PromocionAplicar' } responses: '201': description: Promoción aplicada content: application/json: schema: { $ref: '#/components/schemas/PromocionMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /lotes/{id}/promociones/quitar: parameters: - $ref: '#/components/parameters/Id' post: tags: [Promociones] operationId: quitarPromocion summary: Quitar la promoción activa description: Restaura el estado y el precio anteriores del lote. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Promoción quitada content: application/json: schema: { $ref: '#/components/schemas/PromocionMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } /lotes/{id}/promociones/activa: parameters: - $ref: '#/components/parameters/Id' get: tags: [Promociones] operationId: obtenerPromocionActiva summary: Obtener la promoción activa de un lote description: >- Para INMOBILIARIA, un lote NO_DISPONIBLE responde `data` null, igual que un lote inexistente. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA, TECNICO] security: [{ bearerAuth: [] }] responses: '200': description: Promoción activa, o `data` null si no hay content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: allOf: [{ $ref: '#/components/schemas/Promocion' }] nullable: true '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ RESERVAS /reservas: get: tags: [Reservas] operationId: listarReservas summary: Listar reservas description: INMOBILIARIA ve solo las reservas de su inmobiliaria. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] parameters: - { name: estado, in: query, schema: { $ref: '#/components/schemas/EstadoReserva' } } - { name: estadoOperativo, in: query, schema: { $ref: '#/components/schemas/EstadoOperativo' } } - { name: loteId, in: query, schema: { $ref: '#/components/schemas/IdQuery' } } responses: '200': description: Reservas content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [reservas, total] properties: reservas: { type: array, items: { $ref: '#/components/schemas/Reserva' } } total: { type: integer, description: Cantidad devuelta } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Reservas] operationId: crearReserva summary: Crear reserva description: >- Para INMOBILIARIA la reserva queda siempre a nombre de su inmobiliaria (se ignora `inmobiliariaId`). Para staff, `inmobiliariaId` debe ser una inmobiliaria OPERATIVO: una ELIMINADO responde 409 "La inmobiliaria seleccionada no está disponible para operar." El lote debe estar DISPONIBLE, EN_PROMOCION o CON_PRIORIDAD (400) y sin otra reserva vigente (409). Un lote con prioridad solo lo reserva el dueño de la prioridad (403). Si dos altas compiten por el mismo lote, se crea una sola reserva y la otra responde 409 sin crear nada. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/ReservaCrear' } responses: '201': description: Reserva creada content: application/json: schema: { $ref: '#/components/schemas/ReservaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /reservas/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Reservas] operationId: obtenerReserva summary: Obtener reserva description: INMOBILIARIA solo accede a reservas de su inmobiliaria (403). x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Reserva content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { $ref: '#/components/schemas/Reserva' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } put: tags: [Reservas] operationId: actualizarReserva summary: Actualizar reserva description: >- Actualización parcial (al menos un campo). No se puede cambiar `loteId` ni `inmobiliariaId` de una reserva creada (400); reenviar el mismo valor no es un cambio. Los cambios de `estado` respetan las transiciones del lifecycle (400/409). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/ReservaActualizar' } responses: '200': description: Reserva actualizada content: application/json: schema: { $ref: '#/components/schemas/ReservaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /reservas/inmob/{id}: parameters: - name: id in: path required: true description: Id de la inmobiliaria schema: { $ref: '#/components/schemas/IdPath' } get: tags: [Reservas] operationId: listarReservasPorInmobiliaria summary: Listar reservas de una inmobiliaria description: INMOBILIARIA solo puede consultar su propia inmobiliaria (403). x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Reservas de la inmobiliaria content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { type: array, items: { $ref: '#/components/schemas/Reserva' } } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /reservas/{id}/eliminar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Reservas] operationId: eliminarReserva summary: Dar de baja una reserva (baja lógica) description: >- Marca `estadoOperativo` ELIMINADO. Solo reservas CANCELADA, EXPIRADA o RECHAZADA (409); una ya eliminada responde 409. INMOBILIARIA solo sobre las propias (403). x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Reserva dada de baja content: application/json: schema: { $ref: '#/components/schemas/ReservaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } /reservas/{id}/reactivar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Reservas] operationId: reactivarReserva summary: Reactivar una reserva dada de baja description: Vuelve `estadoOperativo` a OPERATIVO (409 si no estaba eliminada). INMOBILIARIA solo sobre las propias. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Reserva reactivada content: application/json: schema: { $ref: '#/components/schemas/ReservaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } /reservas/{id}/ofertas: parameters: - $ref: '#/components/parameters/Id' get: tags: [Reservas] operationId: listarOfertasReserva summary: Listar ofertas de una reserva description: INMOBILIARIA solo sobre reservas propias (403). x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Ofertas (más reciente primero) content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { type: array, items: { $ref: '#/components/schemas/OfertaReserva' } } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Reservas] operationId: crearOfertaReserva summary: Registrar oferta, contraoferta, aceptación o rechazo description: INMOBILIARIA solo sobre reservas propias (403). Una reserva ya consumida por una venta no admite ofertas (400). x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/OfertaCrear' } responses: '201': description: Oferta registrada content: application/json: schema: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Oferta registrada } data: type: object required: [oferta, reserva] properties: oferta: { $ref: '#/components/schemas/OfertaReserva' } reserva: { $ref: '#/components/schemas/Reserva' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ VENTAS /ventas: get: tags: [Ventas] operationId: listarVentas summary: Listar ventas description: Sin `estadoOperativo` devuelve solo ventas OPERATIVO. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] parameters: - { name: estado, in: query, schema: { $ref: '#/components/schemas/EstadoVenta' } } - { name: estadoOperativo, in: query, schema: { $ref: '#/components/schemas/EstadoOperativo' } } - { name: loteId, in: query, schema: { $ref: '#/components/schemas/IdQuery' } } responses: '200': description: Ventas content: application/json: schema: { $ref: '#/components/schemas/VentaListaResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Ventas] operationId: crearVenta summary: Crear venta description: >- Requiere al menos un comprador (`compradores[]` o `compradorId`). Si el lote tiene una reserva vigente de una inmobiliaria, la venta debe ser de esa misma inmobiliaria y por el monto de la reserva (400). Si el lote tiene una reserva vigente, el cliente de la reserva debe estar entre los compradores (400). `inmobiliariaId` debe ser una inmobiliaria OPERATIVO: una ELIMINADO responde 409 "La inmobiliaria seleccionada no está disponible para operar." Si dos o más ventas compiten por el mismo lote, se crea una sola y las demás responden 409 sin crear nada. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/VentaCrear' } responses: '201': description: Venta creada content: application/json: schema: { $ref: '#/components/schemas/VentaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /ventas/inmobiliaria/{id}: parameters: - name: id in: path required: true description: Id de la inmobiliaria schema: { $ref: '#/components/schemas/IdPath' } get: tags: [Ventas] operationId: listarVentasPorInmobiliaria summary: Listar ventas de una inmobiliaria description: INMOBILIARIA solo puede consultar su propia inmobiliaria (403). Sin resultados responde 404. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] parameters: - { name: estadoOperativo, in: query, schema: { $ref: '#/components/schemas/EstadoOperativo' } } responses: '200': description: Ventas de la inmobiliaria content: application/json: schema: { $ref: '#/components/schemas/VentaListaResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } /ventas/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Ventas] operationId: obtenerVenta summary: Obtener venta x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Venta content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { $ref: '#/components/schemas/Venta' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } put: tags: [Ventas] operationId: actualizarVenta summary: Actualizar venta description: >- Actualización parcial (al menos un campo). Los cambios de `estado` respetan las transiciones válidas. Reasignar `inmobiliariaId` a una inmobiliaria ELIMINADO responde 409; reenviar la inmobiliaria actual de una venta histórica no es una reasignación. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/VentaActualizar' } responses: '200': description: Venta actualizada content: application/json: schema: { $ref: '#/components/schemas/VentaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /ventas/{id}/eliminar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Ventas] operationId: eliminarVenta summary: Dar de baja una venta (baja lógica) description: Marca `estadoOperativo` ELIMINADO si el estado de la venta lo permite (409). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Venta dada de baja content: application/json: schema: { $ref: '#/components/schemas/VentaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } /ventas/{id}/reactivar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Ventas] operationId: reactivarVenta summary: Reactivar una venta dada de baja x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Venta reactivada content: application/json: schema: { $ref: '#/components/schemas/VentaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ PAGOS /ventas/{ventaId}/pagos: parameters: - $ref: '#/components/parameters/VentaId' get: tags: [Pagos] operationId: obtenerContextoPagos summary: Contexto de pagos de una venta description: Plan vigente, cuotas, pagos, planes históricos y resumen. Montos como number. Venta eliminada → 409. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Contexto de pagos content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { $ref: '#/components/schemas/ContextoPagos' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Pagos] operationId: registrarPago summary: Registrar un pago sobre una cuota description: >- Venta eliminada o cancelada → 409 (los pagos ya registrados de una venta cancelada se conservan). Los pagos concurrentes sobre la misma cuota se registran de a uno: cada uno ve el saldo actualizado y, si lo supera, responde 409. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/PagoRegistrar' } responses: '201': description: Pago registrado (montos como number) content: application/json: schema: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Pago registrado correctamente } data: { $ref: '#/components/schemas/PagoRegistrado' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /ventas/{ventaId}/pagos/recargo: parameters: - $ref: '#/components/parameters/VentaId' post: tags: [Pagos] operationId: aplicarRecargo summary: Aplicar un recargo manual a una cuota description: >- Venta eliminada o cancelada → 409. Se aplica de a uno con los pagos de la misma cuota, sobre el saldo actualizado. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/RecargoAplicar' } responses: '201': description: Recargo aplicado content: application/json: schema: { $ref: '#/components/schemas/MensajeResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /ventas/{ventaId}/pagos/plan: parameters: - $ref: '#/components/parameters/VentaId' post: tags: [Pagos] operationId: crearPlanPago summary: Crear el plan de pago inicial description: >- La suma de las cuotas debe coincidir con el monto esperado según el tipo de financiación (400). Venta eliminada o con plan vigente → 409. La respuesta es el plan tal como queda persistido: sus montos son Decimal serializados como string. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/PlanPagoCrear' } responses: '201': description: Plan creado content: application/json: schema: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Plan de pago creado exitosamente } data: { $ref: '#/components/schemas/PlanPagoPersistido' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /ventas/{ventaId}/pagos/plan/reemplazar: parameters: - $ref: '#/components/parameters/VentaId' post: tags: [Pagos] operationId: reemplazarPlanPago summary: Reemplazar el plan de pago vigente description: El plan nuevo cubre el saldo pendiente real; el anterior queda REEMPLAZADO. Montos como number. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/PlanPagoReemplazar' } responses: '201': description: Plan reemplazado content: application/json: schema: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Plan de pago reemplazado correctamente } data: { $ref: '#/components/schemas/ReemplazoPlanResultado' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ FILES /files: post: tags: [Files] operationId: subirArchivo summary: Subir archivo description: >- `multipart/form-data` con el archivo en el campo `file` (PDF, JPG/JPEG, PNG o WebP; máx. 20 MB). BOLETO, ESCRITURA y OTRO requieren `ventaId` de una venta del mismo lote; PLANO e IMAGEN no lo admiten. TECNICO solo puede subir PLANO e IMAGEN (403). x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] requestBody: required: true content: multipart/form-data: schema: { $ref: '#/components/schemas/ArchivoSubir' } responses: '201': description: Archivo subido content: application/json: schema: { $ref: '#/components/schemas/ArchivoMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/FilesInternalError' } /files/venta/{ventaId}: parameters: - $ref: '#/components/parameters/VentaId' get: tags: [Files] operationId: listarArchivosPorVenta summary: Listar archivos de una venta description: >- INMOBILIARIA solo para ventas de su inmobiliaria (404 si no lo es). TECNICO solo recibe PLANO e IMAGEN. `includeDeleted` solo tiene efecto para ADMINISTRADOR y GESTOR. x-roles: [ADMINISTRADOR, GESTOR, TECNICO, INMOBILIARIA] security: [{ bearerAuth: [] }] parameters: - { name: tipo, in: query, schema: { $ref: '#/components/schemas/TipoArchivo' } } - { name: includeDeleted, in: query, schema: { type: string, enum: ['true', 'false'] } } responses: '200': description: Archivos (array, sin envoltorio) content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/Archivo' } } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/FilesInternalError' } /files/lote/{idLoteAsociado}: parameters: - name: idLoteAsociado in: path required: true schema: { $ref: '#/components/schemas/IdPath' } get: tags: [Files] operationId: listarArchivosPorLote summary: Listar archivos de un lote description: >- Cada rol recibe solo los tipos que puede ver (TECNICO: PLANO e IMAGEN; INMOBILIARIA: documentos de lote y de ventas propias). `includeDeleted` solo tiene efecto para ADMINISTRADOR y GESTOR. x-roles: [ADMINISTRADOR, GESTOR, TECNICO, INMOBILIARIA] security: [{ bearerAuth: [] }] parameters: - { name: includeDeleted, in: query, schema: { type: string, enum: ['true', 'false'] } } responses: '200': description: Archivos (array, sin envoltorio) content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/Archivo' } } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/FilesInternalError' } /files/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Files] operationId: obtenerArchivo summary: Obtener metadata de un archivo description: Un archivo que el rol no puede ver responde 404 (TECNICO fuera de PLANO/IMAGEN, INMOBILIARIA fuera de sus ventas). x-roles: [ADMINISTRADOR, GESTOR, TECNICO, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Archivo (sin envoltorio) content: application/json: schema: { $ref: '#/components/schemas/Archivo' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/FilesInternalError' } delete: tags: [Files] operationId: eliminarArchivo summary: Dar de baja un archivo (baja lógica) description: Lo marca ELIMINADO; se puede restaurar. Para borrarlo del storage usar `DELETE /files/{id}/purge`. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '204': { description: Archivo dado de baja } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/FilesInternalError' } /files/{id}/url: parameters: - $ref: '#/components/parameters/Id' post: tags: [Files] operationId: generarUrlFirmada summary: Generar URL firmada de descarga description: Solo archivos OPERATIVO que el rol puede ver (404 si no). La URL es temporal; `expiresAt` indica su vencimiento. x-roles: [ADMINISTRADOR, GESTOR, TECNICO, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: URL firmada content: application/json: schema: { $ref: '#/components/schemas/UrlFirmada' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/FilesInternalError' } /files/{id}/restore: parameters: - $ref: '#/components/parameters/Id' post: tags: [Files] operationId: restaurarArchivo summary: Restaurar un archivo dado de baja x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Archivo restaurado content: application/json: schema: { $ref: '#/components/schemas/ArchivoMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/FilesInternalError' } /files/{id}/purge: parameters: - $ref: '#/components/parameters/Id' delete: tags: [Files] operationId: purgarArchivo summary: Borrar un archivo definitivamente (storage y metadata) x-roles: [ADMINISTRADOR] security: [{ bearerAuth: [] }] responses: '204': { description: Archivo purgado } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/FilesInternalError' } /files/{id}/aprobaciones: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Files] operationId: actualizarAprobacionArchivo summary: Actualizar la aprobación de un plano description: >- Solo archivos PLANO (400). `COMISION` lo pueden aprobar ADMINISTRADOR, GESTOR y TECNICO; `MUNICIPIO`, solo ADMINISTRADOR y GESTOR (403). x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/AprobacionActualizar' } responses: '200': description: Aprobación actualizada content: application/json: schema: { $ref: '#/components/schemas/ArchivoMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/FilesInternalError' } /files/{id}/sustituir: parameters: - $ref: '#/components/parameters/Id' post: tags: [Files] operationId: sustituirArchivo summary: Sustituir el contenido de un archivo description: >- `multipart/form-data` con el archivo nuevo en el campo `file`. Solo BOLETO, ESCRITURA, OTRO o PLANO; TECNICO solo PLANO (404 para tipos que no puede ver). x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] requestBody: required: true content: multipart/form-data: schema: type: object required: [file] properties: file: { type: string, format: binary } responses: '200': description: Archivo sustituido content: application/json: schema: { $ref: '#/components/schemas/ArchivoMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/FilesInternalError' } # ============================================================ PRIORIDADES /prioridades: get: tags: [Prioridades] operationId: listarPrioridades summary: Listar prioridades description: INMOBILIARIA ve solo las de su inmobiliaria. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] parameters: - { name: estado, in: query, schema: { $ref: '#/components/schemas/EstadoPrioridad' } } - { name: estadoOperativo, in: query, schema: { $ref: '#/components/schemas/EstadoOperativo' } } - { name: ownerType, in: query, schema: { $ref: '#/components/schemas/OwnerPrioridad' } } - { name: inmobiliariaId, in: query, schema: { $ref: '#/components/schemas/IdQuery' } } - { name: loteId, in: query, schema: { $ref: '#/components/schemas/IdQuery' } } - { name: fechaInicioDesde, in: query, schema: { type: string, format: date-time } } - { name: fechaInicioHasta, in: query, schema: { type: string, format: date-time } } - { name: fechaFinDesde, in: query, schema: { type: string, format: date-time } } - { name: fechaFinHasta, in: query, schema: { type: string, format: date-time } } responses: '200': description: Prioridades content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [prioridades, total] properties: prioridades: { type: array, items: { $ref: '#/components/schemas/Prioridad' } } total: { type: integer, description: Cantidad devuelta } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Prioridades] operationId: crearPrioridad summary: Crear prioridad description: >- INMOBILIARIA crea a nombre de su inmobiliaria, dentro de su cupo de prioridades activas (409). Staff define `ownerType` (default CCLF) e `inmobiliariaId`; una inmobiliaria ELIMINADO responde 409 "La inmobiliaria seleccionada no está disponible para operar." El lote debe estar DISPONIBLE o EN_PROMOCION y sin otra prioridad activa (409). La base garantiza una sola prioridad ACTIVA por lote: de dos altas concurrentes para el mismo lote entra una y la otra responde 409 "Ya existe una prioridad ACTIVA para este lote". Si el lote cambia de estado entre la validación y el alta, también 409 y no se crea nada. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/PrioridadCrear' } responses: '201': description: Prioridad creada content: application/json: schema: { $ref: '#/components/schemas/PrioridadMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /prioridades/jobs/expire: post: tags: [Prioridades] operationId: expirarPrioridades summary: Expirar prioridades vencidas (ejecución manual) description: >- Expira las prioridades ACTIVA cuya `fechaFin` ya pasó. Es la misma operación que ejecuta el job programado; sirve para forzarla sin esperar al scheduler. Idempotente. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Expiración ejecutada content: application/json: schema: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Se expiraron 2 prioridades } data: type: object required: [expired] properties: expired: { type: integer, minimum: 0 } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /prioridades/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Prioridades] operationId: obtenerPrioridad summary: Obtener prioridad description: INMOBILIARIA solo prioridades propias (403). x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Prioridad content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { $ref: '#/components/schemas/Prioridad' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } patch: tags: [Prioridades] operationId: actualizarPrioridad summary: Actualizar prioridad description: >- INMOBILIARIA solo edita prioridades propias y no puede cambiar `inmobiliariaId` (403). Staff puede reasignarla: a una inmobiliaria ELIMINADO responde 409 y sin cupo, 409. Mantener la inmobiliaria actual de una prioridad histórica no es una reasignación. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/PrioridadActualizar' } responses: '200': description: Prioridad actualizada content: application/json: schema: { $ref: '#/components/schemas/PrioridadMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /prioridades/{id}/cancelar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Prioridades] operationId: cancelarPrioridad summary: Cancelar prioridad description: >- Solo prioridades ACTIVA (400). El estado se verifica al escribir: si otra transición (expiración, cancelación o finalización) la cerró antes, también responde 400 y no se modifica nada. Restaura el lote si sigue CON_PRIORIDAD. INMOBILIARIA solo propias. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Prioridad cancelada content: application/json: schema: { $ref: '#/components/schemas/PrioridadMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } /prioridades/{id}/finalizar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Prioridades] operationId: finalizarPrioridad summary: Finalizar prioridad description: >- Solo prioridades ACTIVA (400). El estado se verifica al escribir: si otra transición (expiración, cancelación o finalización) la cerró antes, también responde 400 y no se modifica nada. Restaura el lote si sigue CON_PRIORIDAD. INMOBILIARIA solo propias. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Prioridad finalizada content: application/json: schema: { $ref: '#/components/schemas/PrioridadMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } /prioridades/{id}/eliminar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Prioridades] operationId: eliminarPrioridad summary: Dar de baja una prioridad (baja lógica) description: Marca `estadoOperativo` ELIMINADO (409 si ya lo está o su estado no lo permite). INMOBILIARIA solo propias. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Prioridad dada de baja content: application/json: schema: { $ref: '#/components/schemas/PrioridadMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } /prioridades/{id}/reactivar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Prioridades] operationId: reactivarPrioridad summary: Reactivar una prioridad dada de baja description: INMOBILIARIA solo propias. 409 si no estaba eliminada. x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] responses: '200': description: Prioridad reactivada content: application/json: schema: { $ref: '#/components/schemas/PrioridadMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ PERSONAS /personas: get: tags: [Personas] operationId: listarPersonas summary: Listar personas description: >- Sin `limit` devuelve el listado completo (sin paginación); `limit` acota la cantidad (las más recientes primero) y `total` es siempre la cantidad total que cumple el filtro. INMOBILIARIA ve solo sus clientes operativos (se ignoran `view`, `includeInactive` y `estado`). x-roles: [ADMINISTRADOR, GESTOR, TECNICO, INMOBILIARIA] security: [{ bearerAuth: [] }] parameters: - name: view in: query schema: { type: string, enum: [ALL, PROPIETARIOS, INQUILINOS, CLIENTES, MIS_CLIENTES] } - { name: q, in: query, description: Búsqueda por nombre, apellido, razón social o identificador, schema: { type: string } } - { name: includeInactive, in: query, schema: { type: string, enum: ['true', 'false'] } } - { name: estado, in: query, schema: { $ref: '#/components/schemas/EstadoOperativo' } } - { name: limit, in: query, schema: { $ref: '#/components/schemas/IdQuery' } } responses: '200': description: Personas content: application/json: schema: type: object required: [success, message, personas, total] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Personas obtenidas exitosamente } personas: { type: array, items: { $ref: '#/components/schemas/Persona' } } total: { type: integer } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Personas] operationId: crearPersona summary: Crear persona description: >- INMOBILIARIA crea clientes de su inmobiliaria (se ignora `inmobiliariaId`). Staff puede asignar `inmobiliariaId` (null = La Federala); una inmobiliaria ELIMINADO responde 409 "La inmobiliaria seleccionada no está disponible para operar." Identificador duplicado → 409. Grupo familiar plano: `jefeDeFamiliaId` debe existir (400 "El jefe de familia especificado no existe") y no ser miembro de otra familia (409 "El titular indicado ya es miembro de otro grupo familiar"). x-roles: [ADMINISTRADOR, GESTOR, INMOBILIARIA] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/PersonaCrear' } responses: '201': description: Persona creada content: application/json: schema: { $ref: '#/components/schemas/PersonaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /personas/cuil/{cuil}: parameters: - name: cuil in: path required: true description: CUIL de 11 dígitos; se aceptan guiones, puntos y espacios. schema: { type: string, example: 20-12345678-3 } get: tags: [Personas] operationId: obtenerPersonaPorCuil summary: Buscar persona por CUIL x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] responses: '200': description: Persona content: application/json: schema: { $ref: '#/components/schemas/PersonaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } /personas/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Personas] operationId: obtenerPersona summary: Obtener persona x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] responses: '200': description: Persona content: application/json: schema: { $ref: '#/components/schemas/PersonaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } put: tags: [Personas] operationId: actualizarPersona summary: Actualizar persona description: >- Actualización parcial (al menos un campo). Una persona eliminada no se edita (409). Reasignar `inmobiliariaId` a una inmobiliaria ELIMINADO responde 409; conservar la actual no es una reasignación. No modifica el grupo familiar: enviar `jefeDeFamiliaId` responde 400 (se gestiona con `/personas/{id}/grupo-familiar/miembros`). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/PersonaActualizar' } responses: '200': description: Persona actualizada content: application/json: schema: { $ref: '#/components/schemas/PersonaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } delete: tags: [Personas] operationId: eliminarPersonaDefinitivamente summary: Eliminar persona definitivamente description: >- Borrado físico. 409 si tiene asociaciones (lotes propios o alquilados, alquileres, reservas, ventas como comprador principal o co-comprador) o si es titular de un grupo familiar con miembros. Una asociación creada mientras corre el borrado también lo impide (409). Solo ADMINISTRADOR. x-roles: [ADMINISTRADOR] security: [{ bearerAuth: [] }] responses: '200': description: Persona eliminada content: application/json: schema: { $ref: '#/components/schemas/MensajeResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } /personas/{id}/desactivar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Personas] operationId: desactivarPersona summary: Dar de baja una persona (baja lógica) description: 409 si ya está eliminada. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Persona dada de baja content: application/json: schema: { $ref: '#/components/schemas/MensajeResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } /personas/{id}/reactivar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Personas] operationId: reactivarPersona summary: Reactivar una persona dada de baja description: 409 si no estaba eliminada. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Persona reactivada content: application/json: schema: { $ref: '#/components/schemas/PersonaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } /personas/{id}/grupo-familiar: parameters: - $ref: '#/components/parameters/Id' get: tags: [Personas] operationId: obtenerGrupoFamiliar summary: Obtener el grupo familiar de un titular x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Grupo familiar content: application/json: schema: allOf: - type: object required: [success] properties: success: { type: boolean, enum: [true] } - $ref: '#/components/schemas/GrupoFamiliar' '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } /personas/{id}/grupo-familiar/miembros: parameters: - $ref: '#/components/parameters/Id' post: tags: [Personas] operationId: crearMiembroFamiliar summary: Agregar un miembro al grupo familiar description: >- El titular debe ser propietario o inquilino activo (400), no estar eliminado (409) y no ser miembro de otra familia (409 "El titular indicado ya es miembro de otro grupo familiar": no hay familias anidadas). El miembro hereda la inmobiliaria del titular: si esa inmobiliaria está ELIMINADO responde 409 "La inmobiliaria seleccionada no está disponible para operar." x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/MiembroFamiliarCrear' } responses: '201': description: Miembro agregado content: application/json: schema: type: object required: [success, miembro, message] properties: success: { type: boolean, enum: [true] } miembro: { $ref: '#/components/schemas/MiembroFamiliarCreado' } message: { type: string, example: Miembro familiar creado exitosamente } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /personas/{id}/grupo-familiar/miembros/{miembroId}: parameters: - $ref: '#/components/parameters/Id' - name: miembroId in: path required: true schema: { $ref: '#/components/schemas/IdPath' } delete: tags: [Personas] operationId: eliminarMiembroFamiliar summary: Quitar un miembro del grupo familiar description: >- Borrado físico del miembro, con los mismos guards que el borrado definitivo de personas: 409 si tiene asociaciones (lotes, alquileres, reservas, ventas o co-compras). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Miembro quitado content: application/json: schema: { $ref: '#/components/schemas/MensajeResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ INMOBILIARIAS /inmobiliarias: get: tags: [Inmobiliarias] operationId: listarInmobiliarias summary: Listar inmobiliarias description: >- Sin `estadoOperativo` devuelve solo las OPERATIVO (uso operativo: selects de asignación). La administración consulta las dadas de baja con `estadoOperativo=ELIMINADO`. `total` cuenta todas las inmobiliarias, sin aplicar el filtro. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] parameters: - { name: estadoOperativo, in: query, schema: { $ref: '#/components/schemas/EstadoOperativo' } } responses: '200': description: Inmobiliarias content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [inmobiliarias, total] properties: inmobiliarias: { type: array, items: { $ref: '#/components/schemas/InmobiliariaConMetricas' } } total: { type: integer, description: Total de inmobiliarias (sin filtro) } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Inmobiliarias] operationId: crearInmobiliaria summary: Crear inmobiliaria x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/InmobiliariaCrear' } responses: '201': description: Inmobiliaria creada content: application/json: schema: { $ref: '#/components/schemas/InmobiliariaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /inmobiliarias/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Inmobiliarias] operationId: obtenerInmobiliaria summary: Obtener inmobiliaria description: Incluye las dadas de baja (ELIMINADO), para historial y reactivación. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Inmobiliaria content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [inmobiliaria] properties: inmobiliaria: { $ref: '#/components/schemas/InmobiliariaConMetricas' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } put: tags: [Inmobiliarias] operationId: actualizarInmobiliaria summary: Actualizar inmobiliaria description: Actualización parcial (al menos un campo). Una inmobiliaria ELIMINADO no se edita (409). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/InmobiliariaActualizar' } responses: '200': description: Inmobiliaria actualizada content: application/json: schema: { $ref: '#/components/schemas/InmobiliariaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /inmobiliarias/{id}/eliminar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Inmobiliarias] operationId: eliminarInmobiliaria summary: Dar de baja una inmobiliaria (baja lógica) description: >- Pasa a ELIMINADO (409 si ya lo está). Desde ese momento: su usuario no puede iniciar sesión y sus tokens dejan de operar (401), no aparece en el listado operativo y no puede asignarse a operaciones nuevas (409). Sus reservas, ventas, prioridades y clientes conservan la relación. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Inmobiliaria dada de baja content: application/json: schema: { $ref: '#/components/schemas/InmobiliariaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } /inmobiliarias/{id}/reactivar: parameters: - $ref: '#/components/parameters/Id' patch: tags: [Inmobiliarias] operationId: reactivarInmobiliaria summary: Reactivar una inmobiliaria dada de baja description: Vuelve a OPERATIVO (409 si ya lo está) y recupera acceso, visibilidad operativa y asignabilidad. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Inmobiliaria reactivada content: application/json: schema: { $ref: '#/components/schemas/InmobiliariaMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ USUARIOS /usuarios: get: tags: [Usuarios] operationId: listarUsuarios summary: Listar usuarios description: Listado completo, sin paginación. Nunca incluye la contraseña. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Usuarios content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { type: array, items: { $ref: '#/components/schemas/Usuario' } } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Usuarios] operationId: crearUsuario summary: Crear usuario description: Un GESTOR no puede crear usuarios con rol ADMINISTRADOR (403). Username o email duplicado → 409. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/UsuarioCrear' } responses: '201': description: Usuario creado content: application/json: schema: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Usuario creado exitosamente } data: type: object required: [usuario, message] properties: usuario: { $ref: '#/components/schemas/Usuario' } message: { type: string } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /usuarios/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Usuarios] operationId: obtenerUsuario summary: Obtener usuario x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] responses: '200': description: Usuario content: application/json: schema: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { $ref: '#/components/schemas/Usuario' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } put: tags: [Usuarios] operationId: actualizarUsuario summary: Actualizar usuario description: >- Actualización parcial (al menos un campo). Un GESTOR no puede asignar el rol ADMINISTRADOR (ni a sí mismo) ni modificar a un usuario que ya es ADMINISTRADOR (403). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/UsuarioActualizar' } responses: '200': description: Usuario actualizado content: application/json: schema: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Usuario actualizado exitosamente } data: type: object required: [user, message] properties: user: { $ref: '#/components/schemas/Usuario' } message: { type: string } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } delete: tags: [Usuarios] operationId: eliminarUsuario summary: Eliminar usuario description: Solo ADMINISTRADOR. Es la única revocación de acceso de una cuenta. x-roles: [ADMINISTRADOR] security: [{ bearerAuth: [] }] responses: '200': description: Usuario eliminado content: application/json: schema: { $ref: '#/components/schemas/MensajeResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ FRACCIONES /fracciones: get: tags: [Fracciones] operationId: listarFracciones summary: Listar fracciones description: Devuelve hasta 10 fracciones (el dominio tiene como máximo 8), con sus lotes. `total` cuenta todas. x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] responses: '200': description: Fracciones content: application/json: schema: type: object required: [success, message, fracciones, total] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Fracciones obtenidas exitosamente } fracciones: { type: array, items: { $ref: '#/components/schemas/Fraccion' } } total: { type: integer } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } post: tags: [Fracciones] operationId: crearFraccion summary: Crear fracción description: El número de fracción es único (409). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/FraccionCrear' } responses: '201': description: Fracción creada content: application/json: schema: { $ref: '#/components/schemas/FraccionMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } /fracciones/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Fracciones] operationId: obtenerFraccion summary: Obtener fracción x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] responses: '200': description: Fracción content: application/json: schema: type: object required: [success, fraccion, message] properties: success: { type: boolean, enum: [true] } fraccion: { $ref: '#/components/schemas/Fraccion' } message: { type: string, example: Fracción obtenida exitosamente } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } put: tags: [Fracciones] operationId: actualizarFraccion summary: Actualizar fracción x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/FraccionActualizar' } responses: '200': description: Fracción actualizada content: application/json: schema: { $ref: '#/components/schemas/FraccionMutacionResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '409': { $ref: '#/components/responses/Conflict' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '500': { $ref: '#/components/responses/InternalError' } delete: tags: [Fracciones] operationId: eliminarFraccion summary: Eliminar fracción description: Borrado físico; no se permite si tiene lotes asociados (400). Solo ADMINISTRADOR. x-roles: [ADMINISTRADOR] security: [{ bearerAuth: [] }] responses: '200': description: Fracción eliminada content: application/json: schema: { $ref: '#/components/schemas/MensajeResponse' } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ UBICACIONES /ubicaciones: get: tags: [Ubicaciones] operationId: listarUbicaciones summary: Listar ubicaciones description: Listado completo, sin paginación; `total` es la cantidad devuelta. x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] responses: '200': description: Ubicaciones content: application/json: schema: type: object required: [success, message, ubicaciones, total] properties: success: { type: boolean, enum: [true] } message: { type: string, example: Ubicaciones obtenidas exitosamente } ubicaciones: { type: array, items: { $ref: '#/components/schemas/Ubicacion' } } total: { type: integer } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /ubicaciones/{id}: parameters: - $ref: '#/components/parameters/Id' get: tags: [Ubicaciones] operationId: obtenerUbicacion summary: Obtener ubicación x-roles: [ADMINISTRADOR, GESTOR, TECNICO] security: [{ bearerAuth: [] }] responses: '200': description: Ubicación content: application/json: schema: type: object required: [success, ubicacion, message] properties: success: { type: boolean, enum: [true] } ubicacion: { $ref: '#/components/schemas/Ubicacion' } message: { type: string, example: Ubicación obtenida exitosamente } '400': { $ref: '#/components/responses/BadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '404': { $ref: '#/components/responses/NotFound' } '500': { $ref: '#/components/responses/InternalError' } # ============================================================ REPORTES /reportes/inventario: get: tags: [Reportes] operationId: reporteInventario summary: Reporte de inventario de lotes description: >- Foto del inventario al corte (día actual en America/Argentina/Buenos_Aires). Universo: lotes de tipo LOTE_VENTA (sin ESPACIO_COMUN), excluidos los de estado ELIMINADO. Los filtros se aplican a los totales y a las filas. Ofrecible = estado DISPONIBLE o EN_PROMOCION, con cualquier subestado. Los totales por estado, fracción y subestado omiten los grupos en cero y siguen el orden del enum (fracciones por número). Filas por número de fracción y número de lote (los lotes sin número, al final). Los precios son siempre USD: la respuesta no incluye moneda. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] parameters: - $ref: '#/components/parameters/ReporteFraccion' - $ref: '#/components/parameters/ReporteEstadoLote' - $ref: '#/components/parameters/ReporteSubestadoLote' responses: '200': description: Reporte de inventario content: application/json: schema: { $ref: '#/components/schemas/ReporteInventarioResponse' } example: success: true data: corte: '2026-11-24' totales: porEstado: - { estado: DISPONIBLE, cantidad: 1 } - { estado: EN_PROMOCION, cantidad: 1 } - { estado: RESERVADO, cantidad: 1 } - { estado: VENDIDO, cantidad: 1 } porFraccion: - { fraccionId: 7, fraccion: 2, cantidad: 2, ofrecibles: 2 } - { fraccionId: 9, fraccion: 3, cantidad: 2, ofrecibles: 0 } porSubestado: - { subestado: CONSTRUIDO, cantidad: 2 } - { subestado: NO_CONSTRUIDO, cantidad: 1 } - { subestado: EN_CONSTRUCCION, cantidad: 1 } ofrecibles: 2 filas: - { loteId: 128, numero: 45, fraccionId: 7, fraccion: 2, estado: DISPONIBLE, subestado: CONSTRUIDO, precio: '85000.00', enlace: '/?lote=128' } - { loteId: 131, numero: 48, fraccionId: 7, fraccion: 2, estado: EN_PROMOCION, subestado: NO_CONSTRUIDO, precio: '72000.50', enlace: '/?lote=131' } - { loteId: 140, numero: 12, fraccionId: 9, fraccion: 3, estado: RESERVADO, subestado: CONSTRUIDO, precio: '90000.00', enlace: '/?lote=140' } - { loteId: 152, numero: null, fraccionId: 9, fraccion: 3, estado: VENDIDO, subestado: EN_CONSTRUCCION, precio: null, enlace: '/?lote=152' } '400': { $ref: '#/components/responses/ReporteInventarioBadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /reportes/inventario.xlsx: get: tags: [Reportes] operationId: exportarReporteInventario summary: Exportar reporte de inventario a Excel description: >- Mismos filtros, validaciones y filas que `GET /reportes/inventario`. Hojas: "Inventario" (ID de lote, Fracción, N.º de lote, Estado, Subestado constructivo, Precio (USD)), "Totales" (ofrecibles, por estado, por fracción y por subestado) y "Parámetros". Archivo `reporte-inventario_corte-YYYY-MM-DD.xlsx` (ejemplo `inventario` del header `Content-Disposition`). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] parameters: - $ref: '#/components/parameters/ReporteFraccion' - $ref: '#/components/parameters/ReporteEstadoLote' - $ref: '#/components/parameters/ReporteSubestadoLote' responses: '200': { $ref: '#/components/responses/ReporteXlsx' } '400': { $ref: '#/components/responses/ReporteInventarioBadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /reportes/ventas: get: tags: [Reportes] operationId: reporteVentas summary: Reporte de ventas por período description: >- Período obligatorio con `desde` <= `hasta` y como máximo 366 días (ambos extremos incluidos), en días calendario de America/Argentina/Buenos_Aires. `periodoAnterior` es el tramo de igual duración que termina el día anterior a `desde`, con las mismas métricas. Cada venta cuenta por su propia fecha: iniciada por `fechaVenta`, escriturada por `fechaEscrituraReal` (estado ESCRITURADO) y cancelada por `fechaCancelacion` (estado CANCELADA). Se excluyen las ventas dadas de baja lógica. La moneda de una venta es la de su plan de pagos (USD si no tiene plan): las tarjetas suman solo USD y cada otra moneda va aparte en `otrasMonedas`, sin convertir. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] parameters: - $ref: '#/components/parameters/ReporteDesde' - $ref: '#/components/parameters/ReporteHasta' - $ref: '#/components/parameters/ReporteFraccion' responses: '200': description: Reporte de ventas content: application/json: schema: { $ref: '#/components/schemas/ReporteVentasResponse' } example: success: true data: corte: '2026-11-24' periodo: { desde: '2026-11-01', hasta: '2026-11-30' } periodoAnterior: { desde: '2026-10-02', hasta: '2026-10-31' } tarjetas: iniciadas: { cantidad: 1, montoUSD: '85000.00', cantidadAnterior: 1, montoUSDAnterior: '72000.50' } escrituradas: { cantidad: 1, montoUSD: '78000.00', cantidadAnterior: 0, montoUSDAnterior: '0.00' } canceladas: { cantidad: 1, montoUSD: '72000.50', cantidadAnterior: 0, montoUSDAnterior: '0.00' } otrasMonedas: - moneda: ARS iniciadas: { cantidad: 1, monto: '95000000.00', cantidadAnterior: 0, montoAnterior: '0.00' } escrituradas: { cantidad: 0, monto: '0.00', cantidadAnterior: 0, montoAnterior: '0.00' } canceladas: { cantidad: 0, monto: '0.00', cantidadAnterior: 0, montoAnterior: '0.00' } filas: - { ventaId: 302, numero: CCLF-2026-302, loteId: 128, loteNumero: 45, fraccionId: 7, fraccion: 2, estado: INICIADA, fechaAlta: '2026-11-12', fechaEscritura: null, fechaCancelacion: null, moneda: USD, monto: '85000.00', enlace: '/ventas?openId=302' } - { ventaId: 305, numero: CCLF-2026-305, loteId: 140, loteNumero: 12, fraccionId: 9, fraccion: 3, estado: INICIADA, fechaAlta: '2026-11-05', fechaEscritura: null, fechaCancelacion: null, moneda: ARS, monto: '95000000.00', enlace: '/ventas?openId=305' } - { ventaId: 299, numero: CCLF-2026-299, loteId: 131, loteNumero: 48, fraccionId: 7, fraccion: 2, estado: CANCELADA, fechaAlta: '2026-10-20', fechaEscritura: null, fechaCancelacion: '2026-11-03', moneda: USD, monto: '72000.50', enlace: '/ventas?openId=299' } - { ventaId: 287, numero: CCLF-2026-287, loteId: 133, loteNumero: 50, fraccionId: 7, fraccion: 2, estado: ESCRITURADO, fechaAlta: '2026-09-18', fechaEscritura: '2026-11-10', fechaCancelacion: null, moneda: USD, monto: '78000.00', enlace: '/ventas?openId=287' } '400': { $ref: '#/components/responses/ReporteVentasBadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /reportes/ventas.xlsx: get: tags: [Reportes] operationId: exportarReporteVentas summary: Exportar reporte de ventas a Excel description: >- Mismos parámetros, validaciones y filas que `GET /reportes/ventas`. Hojas: "Ventas" (ID de venta, N.º de venta, Fracción, N.º de lote, Estado, Fecha de alta, Fecha de escritura, Fecha de cancelación, Moneda, Monto con el formato de su moneda), "Totales" (tarjetas en USD y cada otra moneda aparte, sin sumar) y "Parámetros". Archivo `reporte-ventas_YYYY-MM-DD_a_YYYY-MM-DD_corte-YYYY-MM-DD.xlsx` (desde, hasta y corte; ejemplo `ventas` del header `Content-Disposition`). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] parameters: - $ref: '#/components/parameters/ReporteDesde' - $ref: '#/components/parameters/ReporteHasta' - $ref: '#/components/parameters/ReporteFraccion' responses: '200': { $ref: '#/components/responses/ReporteXlsx' } '400': { $ref: '#/components/responses/ReporteVentasBadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /reportes/cuotas-vencidas: get: tags: [Reportes] operationId: reporteCuotasVencidas summary: Reporte de cuotas vencidas description: >- Saldo vencido al corte en una sola moneda (`moneda` obligatoria; ARS y USD no se mezclan ni se convierten). Cuenta las cuotas de planes VIGENTE en esa moneda con saldo pendiente > 0 y vencimiento anterior al día de corte (America/Argentina/Buenos_Aires): una cuota que vence el día de corte no está vencida. Se excluyen las ventas canceladas y las dadas de baja lógica. El saldo incluye los recargos aplicados y descuenta los pagos parciales. Tramos por días de atraso: 1-30, 31-60 y +60. A diferencia del inventario y de ventas, la fila no trae `fraccionId`: solo `fraccion` (el número visible). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] parameters: - $ref: '#/components/parameters/ReporteMoneda' - $ref: '#/components/parameters/ReporteFraccion' responses: '200': description: Reporte de cuotas vencidas content: application/json: schema: { $ref: '#/components/schemas/ReporteCuotasVencidasResponse' } example: success: true data: corte: '2026-11-24' moneda: USD saldoVencido: '5403.40' cuotas: 4 ventas: 2 tramos: - { tramo: '1-30', cuotas: 2, saldo: '2103.40' } - { tramo: '31-60', cuotas: 1, saldo: '1650.00' } - { tramo: '+60', cuotas: 1, saldo: '1650.00' } filas: - { cuotaId: 921, ventaId: 287, ventaNumero: CCLF-2026-287, loteId: 133, loteNumero: 50, fraccion: 2, numeroCuota: 4, cantidadCuotas: 24, fechaVencimiento: '2026-09-10', diasAtraso: 75, tramo: '+60', saldoPendiente: '1650.00', enlace: /ventas/287/pagos } - { cuotaId: 922, ventaId: 287, ventaNumero: CCLF-2026-287, loteId: 133, loteNumero: 50, fraccion: 2, numeroCuota: 5, cantidadCuotas: 24, fechaVencimiento: '2026-10-10', diasAtraso: 45, tramo: '31-60', saldoPendiente: '1650.00', enlace: /ventas/287/pagos } - { cuotaId: 901, ventaId: 302, ventaNumero: CCLF-2026-302, loteId: 128, loteNumero: 45, fraccion: 2, numeroCuota: 3, cantidadCuotas: 36, fechaVencimiento: '2026-10-29', diasAtraso: 26, tramo: '1-30', saldoPendiente: '1278.00', enlace: /ventas/302/pagos } - { cuotaId: 923, ventaId: 287, ventaNumero: CCLF-2026-287, loteId: 133, loteNumero: 50, fraccion: 2, numeroCuota: 6, cantidadCuotas: 24, fechaVencimiento: '2026-11-10', diasAtraso: 14, tramo: '1-30', saldoPendiente: '825.40', enlace: /ventas/287/pagos } '400': { $ref: '#/components/responses/ReporteCuotasVencidasBadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /reportes/cuotas-vencidas.xlsx: get: tags: [Reportes] operationId: exportarReporteCuotasVencidas summary: Exportar reporte de cuotas vencidas a Excel description: >- Mismos parámetros, validaciones y filas que `GET /reportes/cuotas-vencidas`. Hojas: "Cuotas vencidas" (ID de cuota, N.º de venta, Fracción, N.º de lote, N.º de cuota, Cantidad de cuotas, Vencimiento, Días de atraso, Tramo, Saldo (incluye recargos) en la moneda pedida), "Totales" (saldo vencido, cuotas, ventas afectadas y los 3 tramos) y "Parámetros". Archivo `reporte-cuotas-vencidas__corte-YYYY-MM-DD.xlsx` (ejemplo `cuotasVencidas` del header `Content-Disposition`). x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] parameters: - $ref: '#/components/parameters/ReporteMoneda' - $ref: '#/components/parameters/ReporteFraccion' responses: '200': { $ref: '#/components/responses/ReporteXlsx' } '400': { $ref: '#/components/responses/ReporteCuotasVencidasBadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '500': { $ref: '#/components/responses/InternalError' } /reportes/resumen: post: tags: [Reportes] operationId: resumenReportes summary: Resumen para la reunión con IA description: >- Calcula los 3 reportes con los filtros del body (inventario con `fraccion`; ventas con `desde`, `hasta` y `fraccion`; cuotas vencidas con `moneda` y `fraccion`) y le pasa a Gemini en Vertex AI solo los agregados: sin filas ni datos personales. El frontend nunca envía cifras: el body es estricto y una clave desconocida responde 400. Antes de devolverla, la salida se valida: esquema (`texto` no vacío, `puntos[]` con `tema` del enum y `enlace` interno que empieza con `/reportes`, `datosFaltantes[]`) y que cada número y fecha de `texto`, `puntos[].detalle` y `datosFaltantes[]` esté en la entrada (se aceptan los formatos "255000.00" y "255.000,00", y día, mes y año sueltos de las fechas de la entrada). Un porcentaje o un email en la salida la invalidan. Si la IA no responde, supera el timeout de 15 s o la salida no pasa la validación → 502 `AI_UNAVAILABLE`; los reportes y sus exportaciones siguen funcionando. Límite: 20 resúmenes por usuario por día calendario de America/Argentina/Buenos_Aires. Cuenta cada pedido que llega a la IA, salga bien o mal; un body inválido (400) no consume cupo. Al superarlo responde 429 con `Retry-After` hasta las 00:00 de Argentina. El contador vive en memoria de cada instancia. x-roles: [ADMINISTRADOR, GESTOR] security: [{ bearerAuth: [] }] requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/ReporteResumenRequest' } example: { desde: '2026-11-01', hasta: '2026-11-20', moneda: USD } responses: '200': description: Resumen validado content: application/json: schema: { $ref: '#/components/schemas/ReporteResumenResponse' } example: success: true data: texto: >- Al 2026-11-20 hay 41 lotes ofrecibles: 38 disponibles y 3 en promoción. Entre el 1 y el 20 de noviembre se iniciaron 3 ventas por USD 255.000,00, frente a 5 en el período anterior. Se escrituraron 2 ventas y se canceló 1. Hay 10 cuotas vencidas en USD con un saldo de 7200.00, de las cuales 4800.00 corresponden a la fracción 2. puntos: - { tema: Comercial, detalle: 'Se iniciaron 3 ventas por USD 255000.00 (5 en el período anterior).', enlace: /reportes } - { tema: Cobranzas, detalle: 'La fracción 2 concentra 4800.00 de los 7200.00 vencidos.', enlace: /reportes } - { tema: Inventario, detalle: Quedan 41 lotes ofrecibles y 7 reservados., enlace: /reportes } datosFaltantes: [No hay datos de ventas en ARS para comparar con las de USD.] modelo: gemini-3.5-flash-lite corte: '2026-11-20' '400': { $ref: '#/components/responses/ReporteResumenBadRequest' } '401': { $ref: '#/components/responses/Unauthorized' } '403': { $ref: '#/components/responses/Forbidden' } '413': { $ref: '#/components/responses/PayloadTooLarge' } '429': { $ref: '#/components/responses/ReporteResumenTooManyRequests' } '500': { $ref: '#/components/responses/InternalError' } '502': description: >- La IA no respondió, superó el timeout de 15 s o devolvió una salida que no pasó la validación. El mensaje es público; el detalle queda solo en el log del servidor. content: application/json: schema: { $ref: '#/components/schemas/ErrorResponse' } examples: aiUnavailable: { $ref: '#/components/examples/AiUnavailable' } components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT description: Token obtenido con POST /auth/login, enviado como `Authorization Bearer`. parameters: Id: name: id in: path required: true schema: { $ref: '#/components/schemas/IdPath' } VentaId: name: ventaId in: path required: true schema: { $ref: '#/components/schemas/IdPath' } # Reportes: cada parámetro lo comparten el reporte JSON y su exportación .xlsx. ReporteFraccion: name: fraccion in: query required: false description: >- Id de la fracción (`Fraccion.id`, el `fraccionId` de las respuestas), no su número visible. Sin filtro: todas las fracciones. schema: { $ref: '#/components/schemas/IdQuery' } example: '7' ReporteEstadoLote: name: estado in: query required: false description: >- Estado comercial del lote, con los valores del enum de las respuestas (no los de `EstadoLoteEntrada`). `ELIMINADO` es válido pero siempre da un reporte vacío, porque esos lotes no forman parte del inventario. schema: { $ref: '#/components/schemas/EstadoLote' } example: DISPONIBLE ReporteSubestadoLote: name: subestado in: query required: false description: Subestado constructivo del lote. schema: { $ref: '#/components/schemas/SubestadoLote' } example: CONSTRUIDO ReporteDesde: name: desde in: query required: true description: >- Primer día del período (YYYY-MM-DD, fecha existente, sin hora), incluido. Sin valor por defecto. Debe cumplir `desde` <= `hasta`. schema: { type: string, format: date } example: '2026-11-01' ReporteHasta: name: hasta in: query required: true description: >- Último día del período (YYYY-MM-DD, fecha existente, sin hora), incluido. El período, con ambos extremos, no puede superar 366 días (un año bisiesto completo). Puede ser posterior al día de corte. schema: { type: string, format: date } example: '2026-11-30' ReporteMoneda: name: moneda in: query required: true description: Moneda del reporte. ARS y USD nunca se mezclan ni se convierten. schema: { $ref: '#/components/schemas/Moneda' } example: USD responses: BadRequest: description: >- Datos inválidos. Validación de body, params o query → `VALIDATION_ERROR` con `errors[]`. Regla de negocio o input inválido detectado por la operación → `BAD_REQUEST`. content: application/json: schema: oneOf: - $ref: '#/components/schemas/ValidationErrorResponse' - $ref: '#/components/schemas/ErrorResponse' examples: validacion: value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: id, message: Debe ser un entero positivo }] negocio: value: { success: false, code: BAD_REQUEST, message: El lote no está disponible para reservar. } Unauthorized: description: Token ausente, inválido o vencido, o identidad que ya no opera (usuario eliminado o inmobiliaria dada de baja). content: application/json: schema: { $ref: '#/components/schemas/AuthErrorResponse' } example: { success: false, code: UNAUTHORIZED, message: Token inválido, error: Token inválido } Forbidden: description: >- Rol no admitido por la ruta (incluye el campo legacy `error`) o regla de autorización de la operación (tenant, rol sobre un recurso). content: application/json: schema: { $ref: '#/components/schemas/AuthErrorResponse' } example: { success: false, code: FORBIDDEN, message: No tienes permisos para esta acción, error: No tienes permisos para esta acción } NotFound: description: Recurso inexistente (o ruta inexistente → "Ruta no encontrada"). content: application/json: schema: { $ref: '#/components/schemas/ErrorResponse' } example: { success: false, code: NOT_FOUND, message: Registro no encontrado. } Conflict: description: >- Conflicto con el estado actual. `CONFLICT`: regla de negocio (incluye inmobiliaria ELIMINADO: "La inmobiliaria seleccionada no está disponible para operar."). `CONFLICT_UNIQUE` / `CONFLICT_FK`: restricción de base de datos no traducida por la operación. content: application/json: schema: { $ref: '#/components/schemas/ConflictResponse' } example: { success: false, code: CONFLICT, message: La inmobiliaria seleccionada no está disponible para operar. } PayloadTooLarge: description: Body JSON mayor a 1 MB. content: application/json: schema: { $ref: '#/components/schemas/ErrorResponse' } example: { success: false, code: PAYLOAD_TOO_LARGE, message: El cuerpo de la solicitud supera el tamaño máximo permitido (1mb). } TooManyRequests: description: Demasiados intentos fallidos de login (10 cada 15 minutos por cliente). headers: RateLimit-Policy: schema: { type: string } RateLimit: schema: { type: string } content: application/json: schema: { $ref: '#/components/schemas/ErrorResponse' } example: { success: false, code: TOO_MANY_REQUESTS, message: Demasiados intentos de inicio de sesión. Intentá nuevamente más tarde. } InternalError: description: Error inesperado. El detalle queda solo en el log del servidor. content: application/json: schema: { $ref: '#/components/schemas/ErrorResponse' } example: { success: false, code: INTERNAL_ERROR, message: Error interno. } FilesInternalError: description: Error inesperado en Files. Mismo formato; el mensaje público es propio de la operación. content: application/json: schema: { $ref: '#/components/schemas/ErrorResponse' } example: { success: false, code: INTERNAL_ERROR, message: Error al subir archivo } ReporteXlsx: description: >- Libro de Excel generado con ExcelJS con la hoja de datos del reporte, "Totales" y "Parámetros" (fecha de corte, fecha y hora de generación en Buenos Aires y filtros usados; "Todas"/"Todos" si no se filtró). Montos como número con formato de su moneda (`"USD" #,##0.00`, `"ARS" #,##0.00`; ARS y USD nunca se suman), fechas como fecha de Excel (`dd/mm/yyyy`) y nulos como celda vacía. Con validación fallida, sin token o sin rol la respuesta es el JSON de error, no un archivo. headers: Content-Disposition: description: Descarga con nombre del reporte y fecha de corte (solo `[a-z0-9._-]`). schema: { type: string } examples: inventario: summary: GET /reportes/inventario.xlsx value: attachment; filename="reporte-inventario_corte-2026-11-24.xlsx" ventas: summary: GET /reportes/ventas.xlsx?desde=2026-11-01&hasta=2026-11-30 value: attachment; filename="reporte-ventas_2026-11-01_a_2026-11-30_corte-2026-11-24.xlsx" cuotasVencidas: summary: GET /reportes/cuotas-vencidas.xlsx?moneda=USD value: attachment; filename="reporte-cuotas-vencidas_USD_corte-2026-11-24.xlsx" content: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: schema: { type: string, format: binary } ReporteInventarioBadRequest: description: Query inválida en el reporte de inventario (JSON o .xlsx). content: application/json: schema: { $ref: '#/components/schemas/ValidationErrorResponse' } examples: fraccionNoCanonica: summary: fraccion=07 value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: fraccion, message: Debe ser un entero positivo }] subestadoDesconocido: summary: subestado=TERMINADO value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: subestado, message: 'Invalid option: expected one of "CONSTRUIDO"|"NO_CONSTRUIDO"|"EN_CONSTRUCCION"' }] ReporteVentasBadRequest: description: >- Período inválido en el reporte de ventas (JSON o .xlsx): fecha faltante o inexistente, `desde` posterior a `hasta` o período mayor a 366 días. Las reglas del período se informan en el campo `hasta`. content: application/json: schema: { $ref: '#/components/schemas/ValidationErrorResponse' } examples: fechaInvalida: summary: Sin `desde` y con hasta=2026-02-30 value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: - { field: desde, message: Fecha inválida (formato YYYY-MM-DD) } - { field: hasta, message: Fecha inválida (formato YYYY-MM-DD) } desdePosterior: summary: desde=2026-12-01&hasta=2026-11-01 value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: hasta, message: '`desde` no puede ser posterior a `hasta`' }] periodoMayorA366: summary: desde=2025-01-01&hasta=2026-12-31 value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: hasta, message: El período no puede superar 366 días }] ReporteCuotasVencidasBadRequest: description: Moneda faltante o desconocida, o fracción inválida, en el reporte de cuotas vencidas (JSON o .xlsx). content: application/json: schema: { $ref: '#/components/schemas/ValidationErrorResponse' } examples: monedaFaltante: summary: Sin `moneda` (o con moneda=EUR) value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: moneda, message: 'Invalid option: expected one of "ARS"|"USD"' }] ReporteResumenBadRequest: description: >- Body inválido en el resumen con IA: mismas reglas del período que el reporte de ventas (informadas en `hasta`), `moneda` obligatoria, `fraccion` como id entero positivo y ninguna clave fuera de `desde`, `hasta`, `fraccion` y `moneda` (informada con `field` vacío). No consume cupo del límite diario. content: application/json: schema: { $ref: '#/components/schemas/ValidationErrorResponse' } examples: claveDesconocida: summary: El body trae una cifra (montoUSD) value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: '', message: 'Unrecognized key: "montoUSD"' }] monedaFaltante: summary: Sin `moneda` value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: moneda, message: 'Invalid option: expected one of "ARS"|"USD"' }] desdePosterior: summary: desde 2026-12-01 y hasta 2026-11-01 value: success: false code: VALIDATION_ERROR message: Datos inválidos errors: [{ field: hasta, message: '`desde` no puede ser posterior a `hasta`' }] ReporteResumenTooManyRequests: description: >- Más de 20 resúmenes del usuario en el día calendario de America/Argentina/Buenos_Aires. `Retry-After` indica los segundos que faltan para las 00:00 de Argentina, cuando se reinicia el cupo. headers: Retry-After: description: Segundos hasta las 00:00 del día siguiente en Buenos Aires. schema: { type: integer, minimum: 1 } content: application/json: schema: { $ref: '#/components/schemas/ErrorResponse' } example: { success: false, code: TOO_MANY_REQUESTS, message: Alcanzaste el límite de 20 resúmenes por día. Podés volver a pedirlo mañana. } examples: AiUnavailable: summary: Servicio de IA no disponible (AI_UNAVAILABLE) description: >- Body de error con el contrato común (`ErrorResponse`), del 502 de `POST /reportes/resumen` (CCLF-37). El mensaje es público: no incluye el detalle del proveedor, que queda solo en el log del servidor. value: { success: false, code: AI_UNAVAILABLE, message: No se pudo generar el resumen. Los reportes siguen disponibles. } schemas: # ------------------------------------------------------------ Errores ErrorCode: type: string description: >- Código estable del error, para que el cliente decida sin parsear `message`. `AI_UNAVAILABLE`: el servicio de IA (Gemini en Vertex AI) no respondió, superó el timeout o devolvió una salida que no pasó la validación. Solo lo devuelve `POST /reportes/resumen` (CCLF-37), siempre con status 502. Los reportes y sus exportaciones no dependen de la IA y nunca lo devuelven. Ejemplo de body en `#/components/examples/AiUnavailable`. enum: [BAD_REQUEST, VALIDATION_ERROR, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CONFLICT, CONFLICT_UNIQUE, CONFLICT_FK, PAYLOAD_TOO_LARGE, TOO_MANY_REQUESTS, AI_UNAVAILABLE, INTERNAL_ERROR] ErrorResponse: type: object required: [success, code, message] properties: success: { type: boolean, enum: [false] } code: { $ref: '#/components/schemas/ErrorCode' } message: { type: string, description: Mensaje público } ValidationErrorResponse: type: object required: [success, code, message, errors] properties: success: { type: boolean, enum: [false] } code: { type: string, enum: [VALIDATION_ERROR] } message: { type: string, enum: [Datos inválidos] } errors: type: array items: type: object required: [field, message] properties: field: { type: string, description: Ruta del campo (vacía si la regla es de todo el objeto) } message: { type: string } AuthErrorResponse: allOf: - $ref: '#/components/schemas/ErrorResponse' - type: object properties: error: type: string deprecated: true description: >- Legacy: repite `message`. Lo envían los rechazos de autenticación y de rol de la ruta, por compatibilidad con clientes previos. Usar `message`. ConflictResponse: allOf: - $ref: '#/components/schemas/ErrorResponse' - type: object properties: code: { type: string, enum: [CONFLICT, CONFLICT_UNIQUE, CONFLICT_FK] } MensajeResponse: type: object required: [success, message] properties: success: { type: boolean, enum: [true] } message: { type: string } # ------------------------------------------------------------ Tipos base IdPath: type: integer minimum: 1 maximum: 2147483647 description: Entero positivo canónico (sin ceros a la izquierda, signo, decimales ni exponente). IdQuery: type: string pattern: '^[1-9][0-9]*$' description: Entero positivo canónico (máximo 2147483647). IdEntrada: description: Id entero positivo; se acepta también como string decimal canónico ("12"). oneOf: - { type: integer, minimum: 1, maximum: 2147483647 } - { type: string, pattern: '^[1-9][0-9]*$' } NumeroEntrada: description: Número; se acepta también como string decimal ("1500.50"). oneOf: - { type: number } - { type: string, pattern: '^-?[0-9]+(\.[0-9]+)?$' } FechaEntrada: type: string format: date-time description: Fecha parseable (ISO 8601 recomendado). Decimal: type: string pattern: '^-?[0-9]+(\.[0-9]+)?$' description: Decimal serializado como string (p. ej. "15000.5"). example: '15000.5' # ------------------------------------------------------------ Enums Rol: { type: string, enum: [ADMINISTRADOR, GESTOR, INMOBILIARIA, TECNICO] } EstadoOperativo: { type: string, enum: [OPERATIVO, ELIMINADO] } EstadoLote: type: string description: Estado del lote en las respuestas. enum: [DISPONIBLE, RESERVADO, VENDIDO, NO_DISPONIBLE, EN_PROMOCION, CON_PRIORIDAD, ALQUILADO, OPERATIVO, ELIMINADO] EstadoLoteEntrada: type: string description: Estado del lote en requests y filtros. enum: [Disponible, Reservado, Vendido, No Disponible, En Promoción] SubestadoLote: { type: string, enum: [CONSTRUIDO, NO_CONSTRUIDO, EN_CONSTRUCCION] } SubestadoLoteEntrada: { type: string, enum: [En Construccion, No Construido, Construido] } TipoLote: { type: string, enum: [LOTE_VENTA, ESPACIO_COMUN] } TipoLoteEntrada: { type: string, enum: [Lote Venta, Espacio Comun] } Ocupacion: { type: string, enum: [ALQUILADO, NO_ALQUILADO] } NombreCalle: { type: string, enum: [REINAMORA, MACA, ZORZAL, CAUQUEN, ALONDRA, JACANA, TACUARITO, JILGUERO, GOLONDRINA, CALANDRIA, AGUILAMORA, LORCA, MILANO] } CalleUbicacion: type: string enum: [Reinamora, Maca, Zorzal, Cauquén, Alondra, Jacana, Tacuarito, Jilguero, Golondrina, Calandria, Aguilamora, Lorca, Milano] EstadoReserva: { type: string, enum: [ACTIVA, CANCELADA, ACEPTADA, RECHAZADA, CONTRAOFERTA, EXPIRADA] } EstadoPrioridad: { type: string, enum: [ACTIVA, CANCELADA, FINALIZADA, EXPIRADA] } OwnerPrioridad: { type: string, enum: [INMOBILIARIA, CCLF] } EstadoVenta: { type: string, enum: [INICIADA, CON_BOLETO, ESCRITURADO, CANCELADA] } EstadoCobro: { type: string, enum: [PENDIENTE, EN_CURSO, PAGO_COMPLETO] } TipoArchivo: { type: string, enum: [BOLETO, ESCRITURA, PLANO, IMAGEN, OTRO] } EstadoAprobacion: { type: string, enum: [PENDIENTE, APROBADO, RECHAZADO] } IdentificadorTipo: { type: string, enum: [DNI, CUIL, CUIT, PASAPORTE, OTRO] } TipoFinanciacion: { type: string, enum: [CONTADO, ANTICIPO_CUOTAS, CUOTAS_FIJAS, PERSONALIZADO] } Moneda: { type: string, enum: [ARS, USD] } TipoCuota: { type: string, enum: [ANTICIPO, CUOTA, OTRO] } EstadoCuota: { type: string, enum: [PENDIENTE, PAGO_PARCIAL, PAGA] } MedioPago: { type: string, enum: [EFECTIVO, TRANSFERENCIA, DEPOSITO, CHEQUE, OTRO] } EstadoPlanPago: { type: string, enum: [VIGENTE, REEMPLAZADO, CANCELADO] } # ------------------------------------------------------------ Auth LoginRequest: type: object required: [email, password] properties: email: { type: string, format: email, description: Se normaliza (trim y minúsculas) } password: { type: string, minLength: 6 } LoginData: type: object required: [user, token] properties: token: { type: string, description: JWT para el header Authorization Bearer } user: type: object required: [id, username, email, role, createdAt, inmobiliariaId, inmobiliariaNombre] properties: id: { type: integer } username: { type: string } email: { type: string } role: { $ref: '#/components/schemas/Rol' } createdAt: { type: string, format: date-time } inmobiliariaId: { type: integer, nullable: true } inmobiliariaNombre: { type: string, nullable: true } # ------------------------------------------------------------ Lotes LoteCrear: type: object required: [numero, fraccionId, subestado, tipo, propietarioId] properties: numero: { $ref: '#/components/schemas/NumeroEntrada' } fraccionId: { $ref: '#/components/schemas/IdEntrada' } numPartido: { allOf: [{ $ref: '#/components/schemas/NumeroEntrada' }], description: Default 62 } superficie: { $ref: '#/components/schemas/NumeroEntrada' } estado: { $ref: '#/components/schemas/EstadoLoteEntrada' } subestado: { $ref: '#/components/schemas/SubestadoLoteEntrada' } tipo: { $ref: '#/components/schemas/TipoLoteEntrada' } precio: { $ref: '#/components/schemas/NumeroEntrada' } ocupacion: { $ref: '#/components/schemas/Ocupacion' } alquiler: { type: boolean, deprecated: true, description: Legacy; usar `ocupacion` } deuda: { type: boolean } nombreEspacioComun: { type: string, maxLength: 100 } capacidad: { $ref: '#/components/schemas/NumeroEntrada' } descripcion: { type: string } propietarioId: { $ref: '#/components/schemas/IdEntrada' } inquilinoId: { $ref: '#/components/schemas/IdEntrada' } ubicacionId: { $ref: '#/components/schemas/IdEntrada' } calle: { $ref: '#/components/schemas/NombreCalle' } numeroCalle: { $ref: '#/components/schemas/NumeroEntrada' } LoteActualizar: type: object minProperties: 1 description: Mismos campos que LoteCrear, todos opcionales. properties: numero: { $ref: '#/components/schemas/NumeroEntrada' } fraccionId: { $ref: '#/components/schemas/IdEntrada' } numPartido: { $ref: '#/components/schemas/NumeroEntrada' } superficie: { $ref: '#/components/schemas/NumeroEntrada' } estado: { $ref: '#/components/schemas/EstadoLoteEntrada' } subestado: { $ref: '#/components/schemas/SubestadoLoteEntrada' } tipo: { $ref: '#/components/schemas/TipoLoteEntrada' } precio: { $ref: '#/components/schemas/NumeroEntrada' } ocupacion: { $ref: '#/components/schemas/Ocupacion' } alquiler: { type: boolean, deprecated: true } deuda: { type: boolean } nombreEspacioComun: { type: string, maxLength: 100 } capacidad: { $ref: '#/components/schemas/NumeroEntrada' } descripcion: { type: string } propietarioId: { $ref: '#/components/schemas/IdEntrada' } inquilinoId: { $ref: '#/components/schemas/IdEntrada' } ubicacionId: { $ref: '#/components/schemas/IdEntrada' } calle: { $ref: '#/components/schemas/NombreCalle' } numeroCalle: { $ref: '#/components/schemas/NumeroEntrada' } Lote: type: object description: >- Lote con sus relaciones de presentación (ubicación, propietario, fracción, alquiler activo, promoción). Para TECNICO no incluye `deuda`, ventas ni reservas. required: [id, tipo, estado, subestado, numPartido, fraccionId, propietarioId, createdAt] properties: id: { type: integer } numero: { type: integer, nullable: true } mapId: { type: string, nullable: true } tipo: { $ref: '#/components/schemas/TipoLote' } descripcion: { type: string, nullable: true } estado: { $ref: '#/components/schemas/EstadoLote' } subestado: { $ref: '#/components/schemas/SubestadoLote' } fondo: { allOf: [{ $ref: '#/components/schemas/Decimal' }], nullable: true } frente: { allOf: [{ $ref: '#/components/schemas/Decimal' }], nullable: true } superficie: { allOf: [{ $ref: '#/components/schemas/Decimal' }], nullable: true } precio: { allOf: [{ $ref: '#/components/schemas/Decimal' }], nullable: true } numPartido: { type: integer } alquiler: { type: boolean, nullable: true } deuda: { type: boolean, nullable: true } nombreEspacioComun: { type: string, nullable: true } capacidad: { type: integer, nullable: true } fraccionId: { type: integer } propietarioId: { type: integer } inquilinoId: { type: integer, nullable: true } ocupacion: { $ref: '#/components/schemas/Ocupacion' } createdAt: { type: string, format: date-time } updateAt: { type: string, format: date-time, nullable: true } LoteMutacionResponse: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string } data: { $ref: '#/components/schemas/Lote' } # ------------------------------------------------------------ Promociones PromocionAplicar: type: object required: [precioPromocional] properties: precioPromocional: { $ref: '#/components/schemas/NumeroEntrada' } fin: { type: string, format: date-time, nullable: true, description: Futura; vacía o null = sin fin } explicacion: { type: string, maxLength: 500, nullable: true } Promocion: type: object required: [id, loteId, precioAnterior, precioPromocional, estadoAnterior, inicio, activa] properties: id: { type: integer } loteId: { type: integer } precioAnterior: { $ref: '#/components/schemas/Decimal' } precioPromocional: { $ref: '#/components/schemas/Decimal' } estadoAnterior: { $ref: '#/components/schemas/EstadoLote' } inicio: { type: string, format: date-time } fin: { type: string, format: date-time, nullable: true } activa: { type: boolean } explicacion: { type: string, nullable: true } createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } PromocionMutacionResponse: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string } data: { $ref: '#/components/schemas/Promocion' } # ------------------------------------------------------------ Reservas ReservaCrear: type: object required: [fechaReserva, loteId, clienteId, numero, ofertaInicial, fechaFinReserva] properties: fechaReserva: { $ref: '#/components/schemas/FechaEntrada' } loteId: { $ref: '#/components/schemas/IdEntrada' } clienteId: { $ref: '#/components/schemas/IdEntrada' } inmobiliariaId: allOf: [{ $ref: '#/components/schemas/IdEntrada' }] nullable: true description: null o ausente = La Federala. Ignorado para INMOBILIARIA. sena: { allOf: [{ $ref: '#/components/schemas/NumeroEntrada' }], nullable: true } numero: { type: string, minLength: 3, maxLength: 30 } ofertaInicial: { $ref: '#/components/schemas/NumeroEntrada' } fechaFinReserva: { $ref: '#/components/schemas/FechaEntrada' } ReservaActualizar: type: object minProperties: 1 properties: fechaReserva: { $ref: '#/components/schemas/FechaEntrada' } loteId: { allOf: [{ $ref: '#/components/schemas/IdEntrada' }], description: No se puede cambiar (400) } clienteId: { $ref: '#/components/schemas/IdEntrada' } inmobiliariaId: allOf: [{ $ref: '#/components/schemas/IdEntrada' }] nullable: true description: No se puede cambiar (400) sena: { allOf: [{ $ref: '#/components/schemas/NumeroEntrada' }], nullable: true, description: null quita la seña } estado: { $ref: '#/components/schemas/EstadoReserva' } numero: { type: string, minLength: 3, maxLength: 30 } fechaFinReserva: { $ref: '#/components/schemas/FechaEntrada' } Reserva: type: object description: Reserva con sus relaciones de presentación (cliente, inmobiliaria, lote). required: [id, numero, fechaReserva, estado, estadoOperativo, loteId, clienteId, ofertaInicial, ofertaActual, fechaFinReserva, createdAt] properties: id: { type: integer } numero: { type: string } fechaReserva: { type: string, format: date-time } estado: { $ref: '#/components/schemas/EstadoReserva' } estadoPrevio: { allOf: [{ $ref: '#/components/schemas/EstadoReserva' }], nullable: true } estadoOperativo: { $ref: '#/components/schemas/EstadoOperativo' } fechaBaja: { type: string, format: date-time, nullable: true } loteId: { type: integer } clienteId: { type: integer } inmobiliariaId: { type: integer, nullable: true, description: null = La Federala } sena: { allOf: [{ $ref: '#/components/schemas/Decimal' }], nullable: true } ofertaInicial: { $ref: '#/components/schemas/Decimal' } ofertaActual: { $ref: '#/components/schemas/Decimal' } fechaFinReserva: { type: string, format: date-time } loteEstadoAlCrear: { $ref: '#/components/schemas/EstadoLote' } ventaId: { type: integer, nullable: true } createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } ReservaMutacionResponse: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string } data: { $ref: '#/components/schemas/Reserva' } OfertaCrear: type: object required: [monto] properties: monto: { $ref: '#/components/schemas/NumeroEntrada' } motivo: { type: string } action: { type: string, enum: [CONTRAOFERTAR, ACEPTAR, RECHAZAR] } OfertaReserva: type: object required: [id, reservaId, monto, nombreEfector, ownerType, createdAt] properties: id: { type: integer } reservaId: { type: integer } monto: { $ref: '#/components/schemas/Decimal' } motivo: { type: string, nullable: true } nombreEfector: { type: string } efectorId: { type: integer, nullable: true } ownerType: { $ref: '#/components/schemas/OwnerPrioridad' } createdAt: { type: string, format: date-time } # ------------------------------------------------------------ Ventas CompradorEntrada: type: object required: [personaId] properties: personaId: { $ref: '#/components/schemas/IdEntrada' } VentaCrear: type: object required: [loteId, fechaVenta, monto, tipoPago, numero] description: >- Requiere `compradores[]` o `compradorId`. ESCRITURADO exige `fechaEscrituraReal`; CANCELADA exige `fechaCancelacion` y `motivoCancelacion`. properties: loteId: { $ref: '#/components/schemas/IdEntrada' } fechaVenta: { $ref: '#/components/schemas/FechaEntrada' } monto: { $ref: '#/components/schemas/NumeroEntrada' } estado: { $ref: '#/components/schemas/EstadoVenta' } estadoCobro: { $ref: '#/components/schemas/EstadoCobro' } plazoEscritura: { $ref: '#/components/schemas/FechaEntrada' } fechaEscrituraReal: { $ref: '#/components/schemas/FechaEntrada' } fechaCancelacion: { $ref: '#/components/schemas/FechaEntrada' } motivoCancelacion: { type: string, minLength: 1 } tipoPago: { type: string, minLength: 1 } compradorId: { allOf: [{ $ref: '#/components/schemas/IdEntrada' }], deprecated: true, description: Legacy; usar `compradores` } compradores: { type: array, minItems: 1, items: { $ref: '#/components/schemas/CompradorEntrada' } } inmobiliariaId: { allOf: [{ $ref: '#/components/schemas/IdEntrada' }], description: Ausente = La Federala } reservaId: { allOf: [{ $ref: '#/components/schemas/IdEntrada' }], nullable: true } numero: { type: string, minLength: 3, maxLength: 30 } VentaActualizar: type: object minProperties: 1 properties: loteId: { $ref: '#/components/schemas/IdEntrada' } fechaVenta: { $ref: '#/components/schemas/FechaEntrada' } monto: { $ref: '#/components/schemas/NumeroEntrada' } estado: { $ref: '#/components/schemas/EstadoVenta' } estadoCobro: { $ref: '#/components/schemas/EstadoCobro' } plazoEscritura: { $ref: '#/components/schemas/FechaEntrada' } fechaEscrituraReal: { $ref: '#/components/schemas/FechaEntrada' } fechaCancelacion: { $ref: '#/components/schemas/FechaEntrada' } motivoCancelacion: { type: string, minLength: 1 } tipoPago: { type: string, minLength: 1 } compradorId: { allOf: [{ $ref: '#/components/schemas/IdEntrada' }], deprecated: true } compradores: { type: array, minItems: 1, items: { $ref: '#/components/schemas/CompradorEntrada' } } inmobiliariaId: { $ref: '#/components/schemas/IdEntrada' } numero: { type: string, minLength: 3, maxLength: 30 } Venta: type: object description: Venta con sus relaciones de presentación (lote, compradores, inmobiliaria). required: [id, numero, loteId, fechaVenta, monto, estado, estadoOperativo, estadoCobro, tipoPago, compradorId, createdAt] properties: id: { type: integer } numero: { type: string } loteId: { type: integer } fechaVenta: { type: string, format: date-time } monto: { $ref: '#/components/schemas/Decimal' } estado: { $ref: '#/components/schemas/EstadoVenta' } estadoPrevio: { allOf: [{ $ref: '#/components/schemas/EstadoVenta' }], nullable: true } estadoOperativo: { $ref: '#/components/schemas/EstadoOperativo' } fechaBaja: { type: string, format: date-time, nullable: true } estadoCobro: { $ref: '#/components/schemas/EstadoCobro' } plazoEscritura: { type: string, format: date-time, nullable: true } fechaEscrituraReal: { type: string, format: date-time, nullable: true } fechaCancelacion: { type: string, format: date-time, nullable: true } motivoCancelacion: { type: string, nullable: true } tipoPago: { type: string } compradorId: { type: integer } inmobiliariaId: { type: integer, nullable: true, description: null = La Federala } createdAt: { type: string, format: date-time } updateAt: { type: string, format: date-time, nullable: true } VentaListaResponse: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: { type: array, items: { $ref: '#/components/schemas/Venta' } } VentaMutacionResponse: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string } data: { $ref: '#/components/schemas/Venta' } # ------------------------------------------------------------ Pagos CuotaEntrada: type: object required: [numeroCuota, tipoCuota, fechaVencimiento, montoOriginal] properties: numeroCuota: { $ref: '#/components/schemas/NumeroEntrada' } tipoCuota: { $ref: '#/components/schemas/TipoCuota' } fechaVencimiento: { $ref: '#/components/schemas/FechaEntrada' } montoOriginal: { $ref: '#/components/schemas/NumeroEntrada' } descripcion: { type: string } PlanPagoCrear: type: object required: [nombre, tipoFinanciacion, cantidadCuotas, fechaInicio, cuotas, moneda, montoTotalPlanificado] description: >- `cantidadCuotas` debe coincidir con `cuotas.length`, sin números repetidos ni vencimientos anteriores a `fechaInicio`. CONTADO no admite anticipo; ANTICIPO_CUOTAS lo exige (> 0 y menor al total). properties: nombre: { type: string, minLength: 1, maxLength: 100 } tipoFinanciacion: { $ref: '#/components/schemas/TipoFinanciacion' } moneda: { $ref: '#/components/schemas/Moneda' } montoTotalPlanificado: { $ref: '#/components/schemas/NumeroEntrada' } cantidadCuotas: { $ref: '#/components/schemas/NumeroEntrada' } fechaInicio: { $ref: '#/components/schemas/FechaEntrada' } cuotas: { type: array, minItems: 1, items: { $ref: '#/components/schemas/CuotaEntrada' } } descripcion: { type: string } montoAnticipo: { $ref: '#/components/schemas/NumeroEntrada' } observaciones: { type: string } PlanPagoReemplazar: type: object required: [nombre, tipoFinanciacion, cantidadCuotas, fechaInicio, cuotas] description: Mismas reglas de cuotas que PlanPagoCrear; el total lo fija el saldo pendiente real. properties: nombre: { type: string, minLength: 1, maxLength: 100 } tipoFinanciacion: { $ref: '#/components/schemas/TipoFinanciacion' } moneda: { $ref: '#/components/schemas/Moneda' } cantidadCuotas: { $ref: '#/components/schemas/NumeroEntrada' } fechaInicio: { $ref: '#/components/schemas/FechaEntrada' } cuotas: { type: array, minItems: 1, items: { $ref: '#/components/schemas/CuotaEntrada' } } descripcion: { type: string } montoAnticipo: { $ref: '#/components/schemas/NumeroEntrada' } observaciones: { type: string } PagoRegistrar: type: object required: [cuotaId, fechaPago, monto, medioPago] properties: cuotaId: { $ref: '#/components/schemas/IdEntrada' } fechaPago: { $ref: '#/components/schemas/FechaEntrada' } monto: { $ref: '#/components/schemas/NumeroEntrada' } medioPago: { $ref: '#/components/schemas/MedioPago' } referencia: { type: string } observacion: { type: string } RecargoAplicar: type: object required: [cuotaId, montoRecargo] properties: cuotaId: { $ref: '#/components/schemas/IdEntrada' } montoRecargo: { $ref: '#/components/schemas/NumeroEntrada' } CuotaPago: type: object description: Cuota con montos como number. properties: id: { type: integer } numeroCuota: { type: integer } tipoCuota: { $ref: '#/components/schemas/TipoCuota' } fechaVencimiento: { type: string, format: date-time } montoOriginal: { type: number } montoRecargoManual: { type: number } montoTotalExigible: { type: number } montoPagado: { type: number } saldoPendiente: { type: number } estadoCuota: { $ref: '#/components/schemas/EstadoCuota' } PlanPagoResumen: type: object description: Plan con montos como number. required: [id, nombre, estadoPlan, tipoFinanciacion, moneda, cantidadCuotas, montoTotalPlanificado, montoFinanciado, montoAnticipo, fechaInicio, version] properties: id: { type: integer } nombre: { type: string } estadoPlan: { $ref: '#/components/schemas/EstadoPlanPago' } tipoFinanciacion: { $ref: '#/components/schemas/TipoFinanciacion' } moneda: { $ref: '#/components/schemas/Moneda' } cantidadCuotas: { type: integer } montoTotalPlanificado: { type: number } montoFinanciado: { type: number } montoAnticipo: { type: number } fechaInicio: { type: string, format: date-time } version: { type: integer } descripcion: { type: string, nullable: true } observaciones: { type: string, nullable: true } createdAt: { type: string, format: date-time } createdBy: { type: string, nullable: true } PlanPagoPersistido: type: object description: Plan tal como queda en la base, con sus cuotas. Montos Decimal como string. required: [id, nombre, estadoPlan, tipoFinanciacion, moneda, cantidadCuotas, montoTotalPlanificado, montoFinanciado, montoAnticipo, fechaInicio] properties: id: { type: integer } nombre: { type: string } estadoPlan: { $ref: '#/components/schemas/EstadoPlanPago' } tipoFinanciacion: { $ref: '#/components/schemas/TipoFinanciacion' } moneda: { $ref: '#/components/schemas/Moneda' } cantidadCuotas: { type: integer } montoTotalPlanificado: { $ref: '#/components/schemas/Decimal' } montoFinanciado: { $ref: '#/components/schemas/Decimal' } montoAnticipo: { $ref: '#/components/schemas/Decimal' } fechaInicio: { type: string, format: date-time } ContextoPagos: type: object description: Montos como number. required: [venta, planVigente, cuotas, pagos, resumen, planificacion] properties: venta: type: object properties: id: { type: integer } numero: { type: string } fechaVenta: { type: string, format: date-time } monto: { type: number } estado: { $ref: '#/components/schemas/EstadoVenta' } estadoCobro: { $ref: '#/components/schemas/EstadoCobro' } planVigente: allOf: [{ $ref: '#/components/schemas/PlanPagoResumen' }] nullable: true cuotas: { type: array, items: { $ref: '#/components/schemas/CuotaPago' } } pagos: type: array description: Pagos registrados y la seña de la reserva de origen, del más reciente al más antiguo. items: type: object properties: monto: { type: number } fechaPago: { type: string, format: date-time } esPagoPrevioReserva: { type: boolean } planesHistoricos: { type: array, items: { type: object } } resumen: type: object properties: montoTotalPlanificado: { type: number } montoTotalPagado: { type: number } saldoPendienteTotal: { type: number } cantidadCuotas: { type: integer } cuotasPagas: { type: integer } cuotasPendientes: { type: integer } cuotasVencidas: { type: integer } planificacion: type: object properties: montoVenta: { type: number } montoSenaReserva: { type: number } saldoAPlanificar: { type: number } PagoRegistrado: type: object description: Montos como number. required: [pago, cuota, resumen] properties: pago: type: object properties: id: { type: integer } cuotaId: { type: integer } fechaPago: { type: string, format: date-time } monto: { type: number } medioPago: { $ref: '#/components/schemas/MedioPago' } cuota: { $ref: '#/components/schemas/CuotaPago' } resumen: type: object properties: montoTotalPagado: { type: number } saldoPendienteTotal: { type: number } cuotasPagas: { type: integer } cuotasPendientes: { type: integer } cuotasVencidas: { type: integer } ReemplazoPlanResultado: type: object description: Montos como number. required: [planAnterior, planNuevo, cuotas, saldoPendienteRealUsado, versionAnterior, versionNueva, monedaAplicada] properties: planAnterior: { type: object } planNuevo: { $ref: '#/components/schemas/PlanPagoResumen' } cuotas: { type: array, items: { $ref: '#/components/schemas/CuotaPago' } } saldoPendienteRealUsado: { type: number } versionAnterior: { type: integer } versionNueva: { type: integer } monedaAplicada: { $ref: '#/components/schemas/Moneda' } # ------------------------------------------------------------ Files ArchivoSubir: type: object required: [file, idLoteAsociado, tipo] properties: file: { type: string, format: binary, description: PDF, JPG/JPEG, PNG o WebP; máx. 20 MB } idLoteAsociado: { $ref: '#/components/schemas/IdQuery' } tipo: { $ref: '#/components/schemas/TipoArchivo' } ventaId: allOf: [{ $ref: '#/components/schemas/IdQuery' }] description: Obligatorio para BOLETO, ESCRITURA y OTRO; no admitido para PLANO e IMAGEN. Archivo: type: object required: [id, filename, url, tipo, uploadedAt, idLoteAsociado, ventaId, estadoOperativo] properties: id: { type: integer } filename: { type: string } url: type: string description: Ruta interna del objeto en el storage. No es una URL de descarga; usar POST /files/{id}/url. tipo: { $ref: '#/components/schemas/TipoArchivo' } uploadedAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } uploadedBy: { type: string, nullable: true } idLoteAsociado: { type: integer } ventaId: { type: integer, nullable: true } ventaNumero: { type: string, nullable: true } estadoOperativo: { $ref: '#/components/schemas/EstadoOperativo' } fechaBaja: { type: string, format: date-time, nullable: true } deletedBy: { type: string, nullable: true } estadoAprobacionComision: { allOf: [{ $ref: '#/components/schemas/EstadoAprobacion' }], nullable: true } fechaAprobacionComision: { type: string, format: date-time, nullable: true } aprobadoComisionBy: { type: string, nullable: true } observacionAprobacionComision: { type: string, nullable: true } estadoAprobacionMunicipio: { allOf: [{ $ref: '#/components/schemas/EstadoAprobacion' }], nullable: true } fechaAprobacionMunicipio: { type: string, format: date-time, nullable: true } aprobadoMunicipioBy: { type: string, nullable: true } observacionAprobacionMunicipio: { type: string, nullable: true } ArchivoMutacionResponse: type: object required: [message, data] description: Files no incluye `success` en sus respuestas exitosas. properties: message: { type: string } data: { $ref: '#/components/schemas/Archivo' } AprobacionActualizar: type: object required: [target, estado] properties: target: { type: string, enum: [COMISION, MUNICIPIO] } estado: { $ref: '#/components/schemas/EstadoAprobacion' } observacion: { type: string, maxLength: 500 } UrlFirmada: type: object required: [signedUrl, signedURL, expiresAt] properties: signedUrl: { type: string, format: uri } signedURL: { type: string, format: uri, deprecated: true, description: Legacy; repite signedUrl } expiresAt: { type: string, format: date-time } # ------------------------------------------------------------ Prioridades PrioridadCrear: type: object required: [numero, loteId, fechaInicio, fechaFin] description: fechaFin debe ser posterior a fechaInicio y a la fecha actual. properties: numero: { type: string, minLength: 1 } loteId: { $ref: '#/components/schemas/IdEntrada' } fechaInicio: { $ref: '#/components/schemas/FechaEntrada' } fechaFin: { $ref: '#/components/schemas/FechaEntrada' } ownerType: { allOf: [{ $ref: '#/components/schemas/OwnerPrioridad' }], description: Solo staff; default CCLF } inmobiliariaId: allOf: [{ $ref: '#/components/schemas/IdEntrada' }] nullable: true description: Solo staff con ownerType INMOBILIARIA. Ignorado para INMOBILIARIA. PrioridadActualizar: type: object minProperties: 1 properties: numero: { type: string, minLength: 1 } inmobiliariaId: allOf: [{ $ref: '#/components/schemas/IdEntrada' }] nullable: true description: Solo staff; null la pasa a CCLF. fechaFin: { allOf: [{ $ref: '#/components/schemas/FechaEntrada' }], description: Posterior a la fecha actual } Prioridad: type: object description: Prioridad con su lote e inmobiliaria de presentación. No tiene campos Decimal. required: [id, numero, loteId, estado, estadoOperativo, ownerType, fechaInicio, fechaFin, createdAt] properties: id: { type: integer } numero: { type: string } loteId: { type: integer } estado: { $ref: '#/components/schemas/EstadoPrioridad' } estadoOperativo: { $ref: '#/components/schemas/EstadoOperativo' } ownerType: { $ref: '#/components/schemas/OwnerPrioridad' } inmobiliariaId: { type: integer, nullable: true, description: null cuando el dueño es CCLF } fechaInicio: { type: string, format: date-time } fechaFin: { type: string, format: date-time } loteEstadoAlCrear: { $ref: '#/components/schemas/EstadoLote' } createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } PrioridadMutacionResponse: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string } data: { $ref: '#/components/schemas/Prioridad' } # ------------------------------------------------------------ Personas PersonaCrear: type: object required: [identificadorTipo, identificadorValor] description: >- Requiere `razonSocial` (persona jurídica) o `nombre` y `apellido` (persona física). Formato del identificador: DNI 8 dígitos; CUIL/CUIT 11 dígitos (se quitan guiones); PASAPORTE 6 a 9 caracteres alfanuméricos en mayúscula. properties: identificadorTipo: { $ref: '#/components/schemas/IdentificadorTipo' } identificadorValor: { type: string, minLength: 1 } nombre: { type: string, maxLength: 100 } apellido: { type: string, maxLength: 100 } razonSocial: { type: string, maxLength: 200 } telefono: { type: integer, minimum: 1 } email: { type: string, format: email } jefeDeFamiliaId: { $ref: '#/components/schemas/IdEntrada' } inmobiliariaId: allOf: [{ $ref: '#/components/schemas/IdEntrada' }] nullable: true description: Solo staff; null = La Federala. Ignorado para INMOBILIARIA. PersonaActualizar: type: object minProperties: 1 description: identificadorTipo e identificadorValor deben venir juntos. properties: identificadorTipo: { $ref: '#/components/schemas/IdentificadorTipo' } identificadorValor: { type: string, minLength: 1 } nombre: { type: string, minLength: 1, maxLength: 100 } apellido: { type: string, minLength: 1, maxLength: 100 } razonSocial: { type: string, maxLength: 200 } telefono: { type: integer, minimum: 1, nullable: true } email: { type: string, format: email, nullable: true } estado: { allOf: [{ $ref: '#/components/schemas/EstadoOperativo' }], description: Se ignora; usar desactivar/reactivar } inmobiliariaId: { allOf: [{ $ref: '#/components/schemas/IdEntrada' }], nullable: true } Persona: type: object required: [idPersona, nombre, apellido, razonSocial, identificadorTipo, identificadorValor, estado, inmobiliariaId, esPropietario, esInquilino, esJefeDeFamilia] properties: idPersona: { type: integer } nombre: { type: string } apellido: { type: string } razonSocial: { type: string } identificador: { type: string } identificadorTipo: { $ref: '#/components/schemas/IdentificadorTipo' } identificadorValor: { type: string } email: { type: string } telefono: { type: integer } contacto: { type: string } estado: { $ref: '#/components/schemas/EstadoOperativo' } createdAt: { type: string, format: date-time } inmobiliariaId: { type: integer, nullable: true, description: null = La Federala } inmobiliaria: type: object nullable: true properties: id: { type: integer } nombre: { type: string } esPropietario: { type: boolean } esInquilino: { type: boolean } esJefeDeFamilia: { type: boolean } jefeDeFamilia: type: object nullable: true properties: idPersona: { type: integer } nombre: { type: string } apellido: { type: string } cuil: { type: string } miembrosFamilia: type: array items: type: object properties: idPersona: { type: integer } nombre: { type: string } apellido: { type: string } cuil: { type: string } PersonaMutacionResponse: type: object required: [success, persona, message] properties: success: { type: boolean, enum: [true] } persona: { $ref: '#/components/schemas/Persona' } message: { type: string } GrupoFamiliar: type: object required: [titular, miembros] properties: titular: type: object properties: id: { type: integer } nombre: { type: string } apellido: { type: string } razonSocial: { type: string, nullable: true } identificadorTipo: { $ref: '#/components/schemas/IdentificadorTipo' } identificadorValor: { type: string } miembros: type: array items: type: object properties: id: { type: integer } nombre: { type: string } apellido: { type: string } identificadorTipo: { $ref: '#/components/schemas/IdentificadorTipo' } identificadorValor: { type: string } MiembroFamiliarCrear: type: object required: [nombre, apellido, identificadorTipo, identificadorValor] properties: nombre: { type: string, minLength: 1, maxLength: 100 } apellido: { type: string, minLength: 1, maxLength: 100 } identificadorTipo: { $ref: '#/components/schemas/IdentificadorTipo' } identificadorValor: { type: string, minLength: 1 } MiembroFamiliarCreado: type: object required: [id, nombre, apellido, identificadorTipo, identificadorValor] properties: id: { type: integer } nombre: { type: string } apellido: { type: string } identificadorTipo: { $ref: '#/components/schemas/IdentificadorTipo' } identificadorValor: { type: string } # ------------------------------------------------------------ Inmobiliarias InmobiliariaCrear: type: object required: [nombre, razonSocial] properties: nombre: { type: string, minLength: 1, maxLength: 100 } razonSocial: { type: string, minLength: 1, maxLength: 150 } contacto: { type: string, maxLength: 100 } comxventa: allOf: [{ $ref: '#/components/schemas/NumeroEntrada' }] nullable: true description: Comisión por venta (0 a 100); null equivale a 0. userId: { $ref: '#/components/schemas/IdEntrada' } maxPrioridadesActivas: { allOf: [{ $ref: '#/components/schemas/NumeroEntrada' }], nullable: true } estado: { allOf: [{ $ref: '#/components/schemas/EstadoOperativo' }], description: Default OPERATIVO } InmobiliariaActualizar: type: object minProperties: 1 properties: nombre: { type: string, minLength: 1, maxLength: 100 } razonSocial: { type: string, minLength: 1, maxLength: 150 } contacto: { type: string, maxLength: 100 } comxventa: { allOf: [{ $ref: '#/components/schemas/NumeroEntrada' }], nullable: true } userId: { $ref: '#/components/schemas/IdEntrada' } maxPrioridadesActivas: { allOf: [{ $ref: '#/components/schemas/NumeroEntrada' }], nullable: true } estado: { $ref: '#/components/schemas/EstadoOperativo' } fechaBaja: { type: string, format: date-time, nullable: true } Inmobiliaria: type: object required: [idInmobiliaria, nombre, razonSocial, estado] properties: idInmobiliaria: { type: integer } nombre: { type: string } razonSocial: { type: string } contacto: { type: string } comxventa: { type: number, description: Comisión por venta (number); ausente si no está definida } maxPrioridadesActivas: { type: integer } estado: { $ref: '#/components/schemas/EstadoOperativo' } fechaBaja: { type: string, format: date-time } InmobiliariaConMetricas: allOf: - $ref: '#/components/schemas/Inmobiliaria' - type: object properties: ventasTotales: { type: integer } ventasActivas: { type: integer } reservasTotales: { type: integer } reservasActivas: { type: integer } prioridadesTotales: { type: integer } prioridadesActivas: { type: integer } cantidadVentas: { type: integer, deprecated: true, description: Legacy; igual a ventasTotales } cantidadReservas: { type: integer, deprecated: true, description: Legacy; igual a reservasTotales } InmobiliariaMutacionResponse: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string } data: type: object required: [inmobiliaria, message] properties: inmobiliaria: { $ref: '#/components/schemas/InmobiliariaConMetricas' } message: { type: string } # ------------------------------------------------------------ Usuarios UsuarioCrear: type: object required: [username, password, rol, email] properties: username: { type: string, minLength: 1, maxLength: 30 } password: { type: string, minLength: 6 } rol: { $ref: '#/components/schemas/Rol' } email: { type: string, format: email, maxLength: 100 } UsuarioActualizar: type: object minProperties: 1 properties: username: { type: string, minLength: 1, maxLength: 30 } password: { type: string, minLength: 6 } rol: { $ref: '#/components/schemas/Rol' } email: { type: string, format: email, maxLength: 100 } Usuario: type: object description: Nunca incluye la contraseña. required: [id, username, email, role, createdAt] properties: id: { type: integer } username: { type: string } email: { type: string } role: { $ref: '#/components/schemas/Rol' } createdAt: { type: string, format: date-time } # ------------------------------------------------------------ Fracciones y ubicaciones FraccionCrear: type: object required: [numero] properties: numero: { $ref: '#/components/schemas/IdEntrada' } FraccionActualizar: type: object minProperties: 1 properties: numero: { $ref: '#/components/schemas/IdEntrada' } Fraccion: type: object required: [idFraccion, numero, lotes] properties: idFraccion: { type: integer } numero: { type: integer } lotes: type: array description: Lotes de la fracción (montos Decimal como string). Vacío en las respuestas de alta y edición. items: { type: object } FraccionMutacionResponse: type: object required: [success, message, data] properties: success: { type: boolean, enum: [true] } message: { type: string } data: { $ref: '#/components/schemas/Fraccion' } Ubicacion: type: object required: [id, calle, numero] properties: id: { type: integer } calle: { $ref: '#/components/schemas/CalleUbicacion' } numero: { type: integer } # ------------------------------------------------------------ Reportes FechaCorte: type: string format: date description: Día de corte en America/Argentina/Buenos_Aires (YYYY-MM-DD). PeriodoReporte: type: object required: [desde, hasta] properties: desde: { type: string, format: date } hasta: { type: string, format: date } TarjetaVentas: type: object required: [cantidad, montoUSD, cantidadAnterior, montoUSDAnterior] properties: cantidad: { type: integer } montoUSD: { $ref: '#/components/schemas/Decimal' } cantidadAnterior: { type: integer } montoUSDAnterior: { $ref: '#/components/schemas/Decimal' } TarjetaVentasOtraMoneda: type: object description: Igual que TarjetaVentas, con los montos en la moneda del grupo (sin convertir). required: [cantidad, monto, cantidadAnterior, montoAnterior] properties: cantidad: { type: integer } monto: { $ref: '#/components/schemas/Decimal' } cantidadAnterior: { type: integer } montoAnterior: { $ref: '#/components/schemas/Decimal' } VentasOtraMoneda: type: object description: Ventas de una moneda distinta de USD. Nunca se suman a las tarjetas en USD. required: [moneda, iniciadas, escrituradas, canceladas] properties: moneda: { $ref: '#/components/schemas/Moneda' } iniciadas: { $ref: '#/components/schemas/TarjetaVentasOtraMoneda' } escrituradas: { $ref: '#/components/schemas/TarjetaVentasOtraMoneda' } canceladas: { $ref: '#/components/schemas/TarjetaVentasOtraMoneda' } VentaReporteFila: type: object required: [ventaId, numero, loteId, loteNumero, fraccionId, fraccion, estado, fechaAlta, fechaEscritura, fechaCancelacion, moneda, monto, enlace] properties: ventaId: { type: integer } numero: { type: string, description: Número de la venta (Venta.numero). } loteId: { type: integer } loteNumero: { type: integer, nullable: true, description: Lote.numero (opcional en el schema). } fraccionId: { type: integer } fraccion: { type: integer, description: Número visible de la fracción (Fraccion.numero). } estado: { $ref: '#/components/schemas/EstadoVenta' } fechaAlta: { type: string, format: date, description: Día de Venta.fechaVenta en Buenos Aires. } fechaEscritura: { type: string, format: date, nullable: true, description: Día de Venta.fechaEscrituraReal en Buenos Aires. } fechaCancelacion: { type: string, format: date, nullable: true, description: Día de Venta.fechaCancelacion en Buenos Aires. } moneda: allOf: [{ $ref: '#/components/schemas/Moneda' }] description: Moneda del último plan de pagos de la venta; USD si no tiene plan. monto: { $ref: '#/components/schemas/Decimal' } enlace: { type: string, example: '/ventas?openId=603', description: Ruta del frontend que abre la venta. } InventarioPorEstado: type: object required: [estado, cantidad] properties: estado: { $ref: '#/components/schemas/EstadoLote' } cantidad: { type: integer } InventarioPorFraccion: type: object required: [fraccionId, fraccion, cantidad, ofrecibles] properties: fraccionId: { type: integer } fraccion: { type: integer, description: Número visible de la fracción (Fraccion.numero). } cantidad: { type: integer } ofrecibles: { type: integer } InventarioPorSubestado: type: object required: [subestado, cantidad] properties: subestado: { $ref: '#/components/schemas/SubestadoLote' } cantidad: { type: integer } InventarioFila: type: object required: [loteId, numero, fraccionId, fraccion, estado, subestado, precio, enlace] properties: loteId: { type: integer } numero: { type: integer, nullable: true, description: Lote.numero (opcional en el schema). } fraccionId: { type: integer } fraccion: { type: integer, description: Número visible de la fracción (Fraccion.numero). } estado: { $ref: '#/components/schemas/EstadoLote' } subestado: { $ref: '#/components/schemas/SubestadoLote' } precio: allOf: [{ $ref: '#/components/schemas/Decimal' }] nullable: true description: Precio en USD con 2 decimales; null si el lote no tiene precio. enlace: { type: string, example: '/?lote=128', description: Ruta del frontend que abre el lote. } ReporteInventarioResponse: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [corte, totales, filas] properties: corte: { $ref: '#/components/schemas/FechaCorte' } totales: type: object required: [porEstado, porFraccion, porSubestado, ofrecibles] properties: porEstado: { type: array, items: { $ref: '#/components/schemas/InventarioPorEstado' } } porFraccion: { type: array, items: { $ref: '#/components/schemas/InventarioPorFraccion' } } porSubestado: { type: array, items: { $ref: '#/components/schemas/InventarioPorSubestado' } } ofrecibles: { type: integer } filas: { type: array, items: { $ref: '#/components/schemas/InventarioFila' } } ReporteVentasResponse: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [corte, periodo, periodoAnterior, tarjetas, otrasMonedas, filas] properties: corte: { $ref: '#/components/schemas/FechaCorte' } periodo: { $ref: '#/components/schemas/PeriodoReporte' } periodoAnterior: { $ref: '#/components/schemas/PeriodoReporte' } tarjetas: type: object required: [iniciadas, escrituradas, canceladas] properties: iniciadas: { $ref: '#/components/schemas/TarjetaVentas' } escrituradas: { $ref: '#/components/schemas/TarjetaVentas' } canceladas: { $ref: '#/components/schemas/TarjetaVentas' } otrasMonedas: type: array description: Una entrada por moneda distinta de USD con ventas en alguno de los dos períodos. items: { $ref: '#/components/schemas/VentasOtraMoneda' } filas: type: array description: Ventas que suman en alguna tarjeta del período elegido, por fecha de alta descendente. items: { $ref: '#/components/schemas/VentaReporteFila' } TramoCuotasVencidas: type: object required: [tramo, cuotas, saldo] properties: tramo: { $ref: '#/components/schemas/TramoAtraso' } cuotas: { type: integer } saldo: allOf: [{ $ref: '#/components/schemas/Decimal' }] description: Saldo vencido del tramo, en la moneda del reporte. TramoAtraso: type: string enum: ['1-30', '31-60', '+60'] description: Días de atraso al corte (1 a 30, 31 a 60, más de 60). CuotaVencidaFila: type: object required: [cuotaId, ventaId, ventaNumero, loteId, loteNumero, fraccion, numeroCuota, cantidadCuotas, fechaVencimiento, diasAtraso, tramo, saldoPendiente, enlace] properties: cuotaId: { type: integer } ventaId: { type: integer } ventaNumero: { type: string, description: Número de la venta (Venta.numero). } loteId: { type: integer } loteNumero: { type: integer, nullable: true, description: Lote.numero (opcional en el schema). } fraccion: { type: integer, description: Número visible de la fracción (Fraccion.numero). } numeroCuota: { type: integer } cantidadCuotas: { type: integer, description: Cantidad de cuotas del plan vigente. } fechaVencimiento: { type: string, format: date, description: Día de vencimiento de la cuota. } diasAtraso: { type: integer, description: Días entre el vencimiento y el corte (mínimo 1). } tramo: { $ref: '#/components/schemas/TramoAtraso' } saldoPendiente: allOf: [{ $ref: '#/components/schemas/Decimal' }] description: Saldo pendiente de la cuota (monto exigible con recargos menos lo pagado). enlace: { type: string, example: '/ventas/802/pagos', description: Ruta del frontend que abre los pagos de la venta. } ReporteCuotasVencidasResponse: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [corte, moneda, saldoVencido, cuotas, ventas, tramos, filas] properties: corte: { $ref: '#/components/schemas/FechaCorte' } moneda: { $ref: '#/components/schemas/Moneda' } saldoVencido: allOf: [{ $ref: '#/components/schemas/Decimal' }] description: Suma de saldoPendiente de las cuotas vencidas, en `moneda` (incluye recargos). cuotas: { type: integer, description: Cantidad de cuotas vencidas. } ventas: { type: integer, description: Cantidad de ventas distintas con alguna cuota vencida. } tramos: type: array description: Siempre los 3 tramos, en orden (1-30, 31-60, +60), aunque alguno quede en cero. items: { $ref: '#/components/schemas/TramoCuotasVencidas' } filas: type: array description: Cuotas vencidas, más atrasadas primero (a igual atraso, por cuotaId). items: { $ref: '#/components/schemas/CuotaVencidaFila' } ReporteResumenRequest: type: object additionalProperties: false required: [desde, hasta, moneda] description: Filtros de los 3 reportes. Sin cifras ni claves extra (400). properties: desde: type: string format: date description: Primer día del período de ventas (YYYY-MM-DD), incluido. `desde` <= `hasta`. hasta: type: string format: date description: Último día del período de ventas (YYYY-MM-DD), incluido. Máximo 366 días con ambos extremos. fraccion: allOf: [{ $ref: '#/components/schemas/IdEntrada' }] description: Id de la fracción (`Fraccion.id`), no su número visible. Filtra los 3 reportes. moneda: allOf: [{ $ref: '#/components/schemas/Moneda' }] description: Moneda de las cuotas vencidas. Las ventas se resumen en USD. ReporteResumenResponse: type: object required: [success, data] properties: success: { type: boolean, enum: [true] } data: type: object required: [texto, puntos, datosFaltantes, modelo, corte] properties: texto: { type: string, description: Resumen de 4 a 6 oraciones. Cada número está en la entrada. } puntos: type: array items: type: object required: [tema, detalle, enlace] properties: tema: { type: string, enum: [Comercial, Cobranzas, Inventario] } detalle: { type: string } enlace: { type: string, pattern: '^/reportes', example: /reportes, description: Ruta interna del módulo Reportes. } datosFaltantes: type: array description: Datos que el modelo indicó que faltan para describir algo. items: { type: string } modelo: { type: string, example: gemini-3.5-flash-lite, description: Modelo configurado (AI_SUMMARY_MODEL). } corte: { $ref: '#/components/schemas/FechaCorte' }