first commit

This commit is contained in:
2025-03-05 20:39:27 -06:00
commit c182ae552c
32 changed files with 3742 additions and 0 deletions

View File

@ -0,0 +1,97 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('fixed_assets', function (Blueprint $table) {
$table->smallIncrements('id'); // ID del activo fijo
// Información básica del activo
$table->string('name', 100)->index(); // Nombre del activo
$table->string('asset_code', 50)->unique(); // Código único para identificar el activo
$table->string('description')->nullable(); // Descripción del activo
$table->string('model')->nullable(); // Modelo del activo
$table->string('manufacturer')->nullable(); // Fabricante del activo
$table->unsignedSmallInteger('year_of_manufacture')->nullable(); // Año de fabricación
$table->date('purchase_date')->nullable(); // Fecha de compra
$table->decimal('purchase_price', 10, 2)->unsigned(); // Precio de compra
$table->decimal('salvage_value', 10, 2)->unsigned()->nullable(); // Valor residual
$table->unsignedSmallInteger('useful_life_years')->nullable(); // Vida útil en años
// Cálculo de depreciación
$table->decimal('depreciation_rate', 5, 2)->unsigned(); // Tasa de depreciación
$table->decimal('depreciation_expense', 10, 2)->unsigned()->default(0); // Gastos de depreciación acumulados
// Especificaciones adicionales
$table->decimal('hourly_cost', 8, 2)->unsigned()->default(0); // Costo por hora de uso
$table->string('location')->nullable(); // Ubicación del activo
// Estado del activo
$table->unsignedTinyInteger('status')->index(); // 'available', 'in_maintenance', 'out_of_service'
// Auditoría
$table->unsignedMediumInteger('created_by')->index(); // Usuario que creó el registro
$table->unsignedMediumInteger('updated_by')->index(); // Último usuario que actualizó el registro
$table->timestamps();
// Relaciones
$table->foreign('created_by')->references('id')->on('users')->onDelete('restrict');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('restrict');
});
Schema::create('fixed_asset_status_history', function (Blueprint $table) {
$table->smallIncrements('id'); // ID del historial
$table->unsignedSmallInteger('fixed_asset_id')->index(); // Relación con el activo fijo
$table->unsignedTinyInteger('status'); // Estado del activo (por ejemplo, disponible, en mantenimiento, fuera de servicio)
$table->date('status_change_date'); // Fecha del cambio de estado
$table->mediumText('notes')->nullable(); // Notas sobre el cambio de estado
// Auditoría
$table->unsignedMediumInteger('created_by')->index(); // Usuario que creó el registro
$table->timestamps();
// Relaciones
$table->foreign('fixed_asset_id')->references('id')->on('fixed_assets')->onDelete('cascade');
$table->foreign('created_by')->references('id')->on('users')->onDelete('restrict');
});
Schema::create('fixed_asset_events', function (Blueprint $table) {
$table->smallIncrements('id'); // ID del evento
$table->unsignedSmallInteger('fixed_asset_id')->index(); // Relación con el activo fijo
$table->date('event_date'); // Fecha del evento (mantenimiento, inspección fiscal, etc.)
$table->string('event_type'); // Tipo de evento (mantenimiento, auditoría, etc.)
$table->string('frequency')->nullable(); // Frecuencia del evento (por ejemplo, mensual, trimestral)
$table->mediumText('notes')->nullable(); // Notas sobre el evento
// Auditoría
$table->unsignedMediumInteger('created_by')->index(); // Usuario que creó el evento
$table->timestamps();
// Relaciones
$table->foreign('fixed_asset_id')->references('id')->on('fixed_assets')->onDelete('cascade');
$table->foreign('created_by')->references('id')->on('users')->onDelete('restrict');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('fixed_assets_tables');
}
};