Skip to main content

List All Commercial Spaces

Returns all commercial spaces with their relationships including estadoInmueble, torre.proyecto, and pisoTorre.

Response Fields

success
boolean
Indicates if the request was successful
data
array
Array of commercial space objects
{
  "success": true,
  "data": [
    {
      "id_local": 1,
      "numero": "L-01",
      "id_estado_inmueble": 1,
      "area_total_local": "45.50",
      "id_torre": 1,
      "id_piso_torre": 1,
      "valor_m2": "3500000.00",
      "valor_total": "159250000.00",
      "estadoInmueble": {
        "nombre": "Disponible"
      },
      "torre": {
        "nombre_torre": "Torre A",
        "proyecto": {
          "nombre": "Torre del Sol"
        }
      },
      "pisoTorre": {
        "nivel": 1
      }
    }
  ]
}

Get Single Commercial Space

Retrieve detailed information about a specific commercial space with all relationships.

Path Parameters

id
integer
required
The unique identifier of the commercial space
{
  "success": true,
  "data": {
    "id_local": 1,
    "numero": "L-01",
    "area_total_local": "45.50",
    "valor_m2": "3500000.00",
    "valor_total": "159250000.00",
    "estadoInmueble": {
      "nombre": "Disponible"
    },
    "torre": {
      "nombre_torre": "Torre A",
      "proyecto": {
        "nombre": "Torre del Sol",
        "ubicacion": {
          "direccion": "Calle 123 #45-67",
          "ciudad": {
            "nombre": "Bogotá"
          }
        }
      }
    },
    "pisoTorre": {
      "nivel": 1
    }
  }
}

Create Commercial Space

Create a new commercial space. The system validates that:
  • The floor belongs to the specified tower
  • The space number is unique within the tower

Request Body

numero
string
required
Space number (max 20 characters, must be unique per tower)
id_estado_inmueble
integer
required
Property status ID (must exist in estado_inmueble table)
area_total_local
decimal
Total area in square meters (min: 0, max: 99999999.99)
id_torre
integer
required
Tower ID (must exist in torre table)
id_piso_torre
integer
required
Floor ID (must exist in piso_torre table and belong to the specified tower)
valor_total
decimal
Total value (min: 0, max: 999999999.99)
{
  "numero": "L-01",
  "id_estado_inmueble": 1,
  "area_total_local": 45.50,
  "id_torre": 1,
  "id_piso_torre": 1,
  "valor_total": 159250000.00
}
{
  "success": true,
  "message": "Local creado exitosamente",
  "data": {
    "id_local": 1,
    "numero": "L-01",
    "area_total_local": "45.50",
    "valor_total": "159250000.00"
  }
}
{
  "success": false,
  "message": "El piso seleccionado no pertenece a la torre indicada"
}
{
  "success": false,
  "message": "Ya existe un local con este número en la torre seleccionada"
}

Update Commercial Space

Update an existing commercial space. Same validation rules as creation.

Path Parameters

id
integer
required
The unique identifier of the commercial space to update

Request Body

Same as Create Commercial Space endpoint.

Delete Commercial Space

Delete a commercial space.

Path Parameters

id
integer
required
The unique identifier of the commercial space to delete
{
  "success": true,
  "message": "Local eliminado exitosamente"
}

Change Commercial Space Status

Update the status of a commercial space.

Path Parameters

id
integer
required
The commercial space ID

Request Body

id_estado_inmueble
integer
required
New property status ID
{
  "id_estado_inmueble": 2
}
{
  "success": true,
  "message": "Estado del local actualizado exitosamente",
  "data": {
    "id_local": 1,
    "numero": "L-01",
    "estadoInmueble": {
      "nombre": "Vendido"
    }
  }
}

Filter Commercial Spaces

By Tower

Also available at: /api/torres/{id_torre}/locales
Returns spaces ordered by floor and number.

By Floor

Also available at: /api/pisos/{id_piso_torre}/locales

By Status

By Project

Also available at: /api/proyectos/{id_proyecto}/locales

Search Commercial Spaces

Search commercial spaces by number (case-insensitive).

Query Parameters

termino
string
required
Search term (min 1 character)

Filter by Area Range

Find commercial spaces within a specific area range.

Query Parameters

area_min
decimal
required
Minimum area in square meters (min: 0)
area_max
decimal
required
Maximum area in square meters (must be >= area_min)
GET /api/local/by-rango-area?area_min=40&area_max=60
{
  "success": true,
  "data": [
    {
      "id_local": 1,
      "numero": "L-01",
      "area_total_local": "45.50",
      "valor_total": "159250000.00"
    },
    {
      "id_local": 2,
      "numero": "L-02",
      "area_total_local": "52.30",
      "valor_total": "183050000.00"
    }
  ]
}

Get Commercial Space Summary

Get a comprehensive summary of a commercial space.

Path Parameters

id
integer
required
The commercial space ID
{
  "success": true,
  "data": {
    "id_local": 1,
    "numero": "L-01",
    "area_total": "45.50",
    "torre": "Torre A",
    "piso": 1,
    "proyecto": "Torre del Sol",
    "ubicacion": "Calle 123 #45-67, Bogotá",
    "estado": "Disponible",
    "valor_total": "159250000.00"
  }
}

Get Commercial Space Statistics by Project

Also available at: /api/proyectos/{id_proyecto}/locales/estadisticas
Get aggregated statistics for all commercial spaces in a project.

Path Parameters

id_proyecto
integer
required
The project ID
{
  "success": true,
  "data": {
    "total_locales": 10,
    "area_total": "520.50",
    "area_promedio": "52.05",
    "por_estado": [
      {
        "estado": "Disponible",
        "cantidad": 6,
        "area_total": "312.30",
        "valor_total": "1092050000.00"
      },
      {
        "estado": "Vendido",
        "cantidad": 3,
        "area_total": "156.15",
        "valor_total": "546525000.00"
      },
      {
        "estado": "Reservado",
        "cantidad": 1,
        "area_total": "52.05",
        "valor_total": "182175000.00"
      }
    ]
  }
}

Get Available Commercial Spaces by Project

Also available at: /api/proyectos/{id_proyecto}/locales/disponibles
Retrieve all available commercial spaces in a project (status contains “disponible”).

Path Parameters

id_proyecto
integer
required
The project ID

Model Structure

Database Table: locales

FieldTypeNullableDescription
id_localIntegerNoPrimary key
numeroString(20)NoSpace number
id_estado_inmuebleIntegerNoForeign key to estado_inmueble
area_total_localDecimal(10,2)YesTotal area in m²
id_torreIntegerNoForeign key to torre
id_piso_torreIntegerNoForeign key to piso_torre
valor_m2Decimal(18,2)YesPrice per square meter
valor_totalDecimal(18,2)YesTotal value

Relationships

  • BelongsTo: estadoInmueble (EstadoInmueble)
  • BelongsTo: torre (Torre)
  • BelongsTo: pisoTorre (PisoTorre)
  • HasMany: ventas (Venta)

Computed Attributes

  • valor_comercial: Returns valor_total

Business Rules

Commercial spaces typically are located on lower floors (ground floor or first few levels). When creating a commercial space, ensure the floor is appropriate for retail/commercial use.
The area_total_local field is critical for commercial spaces as pricing often depends on square meters. Many queries and reports aggregate by area.

Build docs developers (and LLMs) love