Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alber1802/AvaluoVehicular/llms.txt

Use this file to discover all available pages before exploring further.

The appraisal value in Avalúo Vehicular is not a subjective estimate — it is the result of multiplying a vehicle’s market reference price (precio_referencial) by three independent depreciation factors that quantify age, usage, and physical condition. Each factor produces a coefficient between 0 and 1 representing the percentage of value retained in that dimension. The three factors are then combined with a replacement-cost markup and a residual-value floor to produce a final, auditable final_estimacion figure stored in the avaluo table.

Final Value Formula

The complete calculation is performed in AvaluoController::index(). All three factors are computed first, then the final value is assembled:
// app/Http/Controllers/Registro/AvaluoController.php

$factor_c = $this->evaluar_inspeccion($vehiculo->id);  // Factor C — inspection
$factor_a = $this->DepreciacionModelo($vehiculo->id);  // Factor A — model age
$factor_b = $this->DepreciacionKilometraje($vehiculo->id); // Factor B — mileage

$p = $vehiculo->precio_referencial;
$factorReposicion = 1.2;

$valorAvaluo = $p * $factor_c * $factor_a * $factor_b * $factorReposicion;

$valorResidualVehiculo = $vehiculo->precio_referencial * 0.107;

$valorFinal = max($valorAvaluo, $valorResidualVehiculo);
if ($valorFinal >= $vehiculo->precio_referencial) {
    $valorFinal = $p * $factor_c * $factor_a * $factor_b;
}
Expressed as pseudocode:
valorAvaluo    = precio_referencial × factor_C × factor_A × factor_B × factor_reposicion (1.2)
valorResidual  = precio_referencial × 0.107

valorFinal     = max(valorAvaluo, valorResidual)

if valorFinal >= precio_referencial:
    valorFinal = precio_referencial × factor_C × factor_A × factor_B
The final if guard ensures the appraised value never equals or exceeds the original reference price. If the combination of factors and the 20 % replacement markup would push the result above market value, the markup factor is dropped and only the raw depreciation factors are applied.

Factor A — Depreciation by Model Age (depre_modelo)

Factor A penalises a vehicle for calendar age. The older the vehicle, the lower the factor. The rate of decay is brand-specific: premium brands typically carry a lower tasa_k (slower annual depreciation), while economy brands may depreciate faster. Formula:
antigüedad = current_year − año_fabricacion
factor_A   = max(1 − (tasa_k × antigüedad), valor_residual)
  • tasa_k — annual depreciation rate, stored per brand in marca_vehiculo.tasa_k
  • valor_residual — minimum factor floor for that brand, stored in marca_vehiculo.valor_residual; prevents factor_A from reaching zero no matter how old the vehicle is
PHP implementation:
// app/Http/Controllers/Registro/AvaluoController.php

public function DepreciacionModelo($id)
{
    $vehiculo = Vehiculo::where('id', $id)->first();
    $marca = MarcaVehiculo::where('id', $vehiculo->id_marca)->first();

    $añoActual = now()->format('Y');
    $añoFabricacion = $vehiculo->año_fabricacion;

    $antiguedad = $añoActual - $añoFabricacion;

    $tasa_k = $marca->tasa_k;
    $valorResidual = $marca->valor_residual;

    $depreciacionModelo = max(1 - ($tasa_k * $antiguedad), $valorResidual);

    return $depreciacionModelo;
}
Example: A brand with tasa_k = 0.08 and valor_residual = 0.20 on a vehicle that is 5 years old:
factor_A = max(1 − (0.08 × 5), 0.20) = max(0.60, 0.20) = 0.60

Factor B — Depreciation by Mileage (depre_kilometraje)

Factor B penalises a vehicle for total distance driven. The formula uses a fixed universal rate of 0.000001 per kilometre (i.e. each 1,000 km reduces the factor by 0.001), with a hard floor of 0.05 so that even extremely high-mileage vehicles retain 5 % of their value under this dimension. Formula:
factor_B = max(1 − (0.000001 × kilometraje), 0.05)
PHP implementation:
// app/Http/Controllers/Registro/AvaluoController.php

public function DepreciacionKilometraje($id)
{
    $vehiculo = Vehiculo::where('id', $id)->first();
    $kilometraje = (int) $vehiculo->kilometraje;

    $depreciacionKilometraje = max(1 - (0.000001 * $kilometraje), 0.05);

    return $depreciacionKilometraje;
}
Example: A vehicle with 50,000 km on the odometer:
factor_B = max(1 − (0.000001 × 50,000), 0.05) = max(0.95, 0.05) = 0.95

Factor C — Depreciation by Inspection (depre_inspeccion)

Factor C is the most complex factor. It is a weighted composite of two sub-scores:
  • Tecnica (65 %) — derived from the mechanical/technical systems inspection (sistemas table)
  • Fallas (35 %) — derived from the visual fault inspection (inspeccion table)
Formula:
factor_C  = (pesoTecnica × Tecnica + pesoFallas × fallas) / 100

pesoTecnica = 65
pesoFallas  = 35

Tecnica     = 1 − Σ(valoracion × estado)   for all sistema rows
fallas      = 1 − Σ(valoracion)             for inspeccion rows where tiene = 1

Tecnica Sub-Score

Each mechanical system row has a valoracion (its weight in the overall technical assessment) and an estado (a JSON-encoded condition value). The product of each component’s weight and condition state is summed, then subtracted from 1 to give the retained condition factor.
// app/Http/Controllers/Registro/AvaluoController.php

public function Tecnica($id)
{
    $vehiculo = Vehiculo::where('id', $id)->first();
    $tecnicas = Sistema::where('id_vehiculo', $vehiculo->id)->get();
    $valorTecnicas = 0;

    foreach ($tecnicas as $tecnica) {
        if ($tecnica->valoracion != null) {
            $valorTecnicas += $tecnica->valoracion * $tecnica->estado;
        }
    }

    return 1 - $valorTecnicas;
}

Fallas Sub-Score

For fault inspections, only rows where tiene = 1 (the fault is present) contribute to the deduction. Their valoracion weights are summed and subtracted from 1.

Combined Factor C

// app/Http/Controllers/Registro/AvaluoController.php

public function evaluar_inspeccion($id)
{
    $pesoFallas   = 35; // weight assigned to fault inspection
    $pesoTecnica  = 65; // weight assigned to technical inspection
    $inspeccion   = Inspeccion::where('id_vehiculo', $id)->get();

    $Tecnica = $this->Tecnica($id);

    $data = $inspeccion->toArray();
    $suma = 0;
    foreach ($data as $item) {
        if ($item['tiene'] == 1) {
            $suma += $item['valoracion'];
        }
    }
    $fallas = 1 - $suma;

    $total = round(($pesoTecnica * $Tecnica + $pesoFallas * $fallas) / 100, 3);

    return $total;
}
Example: A vehicle where the technical score is 0.90 and faults reduce the fallas score to 0.85:
factor_C = (65 × 0.90 + 35 × 0.85) / 100
         = (58.5 + 29.75) / 100
         = 88.25 / 100
         = 0.883 (rounded to 3 decimal places)

Factor Reposicion

The replacement cost factor is a fixed constant of 1.2 applied to account for the 20 % premium typically required to source and install a comparable replacement vehicle (transport, import duties, registration). It is stored in avaluo.factor_reposicion for auditability.
$factorReposicion = 1.2;
$valorAvaluo = $p * $factor_c * $factor_a * $factor_b * $factorReposicion;
The factor is only applied in the valorAvaluo computation. The final guard removes it if the result would equal or exceed the reference price — ensuring the replacement markup never inflates the appraisal beyond market value.

Residual Value Floor

No vehicle can be appraised below 10.7 % of its reference price, regardless of age, mileage, or inspection results. This floor protects appraisals of heavily worn or very old vehicles from yielding unrealistically low values.
$valorResidualVehiculo = $vehiculo->precio_referencial * 0.107;
$valorFinal = max($valorAvaluo, $valorResidualVehiculo);

Complete Worked Example

ParameterValue
precio_referencial$10,000
tasa_k (brand)0.08
valor_residual (brand)0.20
año_fabricacion5 years ago
kilometraje50,000 km
Tecnica sub-score0.90
fallas sub-score0.85
Step 1 — Factor A (age):
factor_A = max(1 − (0.08 × 5), 0.20) = max(0.60, 0.20) = 0.600
Step 2 — Factor B (mileage):
factor_B = max(1 − (0.000001 × 50,000), 0.05) = max(0.95, 0.05) = 0.950
Step 3 — Factor C (inspection):
factor_C = (65 × 0.90 + 35 × 0.85) / 100 = 88.25 / 100 = 0.883
Step 4 — Appraisal value with replacement markup:
valorAvaluo = 10,000 × 0.883 × 0.600 × 0.950 × 1.2
            = 10,000 × 0.603972
            = $6,039.72
Step 5 — Residual floor check:
valorResidual = 10,000 × 0.107 = $1,070
valorFinal    = max(6,039.72, 1,070) = $6,039.72
Step 6 — Reference price ceiling check:
6,039.72 < 10,000  → no adjustment needed
Final appraisal value: $6,039.72
Brand-specific depreciation rates (tasa_k and valor_residual) are managed by administrators at /admin/depreciation (the MarcaVehiculo management panel). Adjusting these rates immediately affects all future appraisal calculations for vehicles of that brand. See the Data Model Reference for the full MarcaVehiculo field list.

Build docs developers (and LLMs) love