- Laravel 11 backend with API REST - React 18 + TypeScript + Vite frontend - Multi-parser architecture for accounting systems (CONTPAQi, Aspel, SAP) - 27+ financial metrics calculation - PDF report generation with Browsershot - Complete documentation (10 documents) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Umbral extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'umbrales';
|
|
|
|
protected $fillable = [
|
|
'metrica',
|
|
'muy_positivo',
|
|
'positivo',
|
|
'neutral',
|
|
'negativo',
|
|
'muy_negativo',
|
|
'giro_id',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'muy_positivo' => 'decimal:4',
|
|
'positivo' => 'decimal:4',
|
|
'neutral' => 'decimal:4',
|
|
'negativo' => 'decimal:4',
|
|
'muy_negativo' => 'decimal:4',
|
|
];
|
|
}
|
|
|
|
public function giro(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Giro::class);
|
|
}
|
|
|
|
public function evaluarValor(float $valor): string
|
|
{
|
|
if ($this->muy_positivo !== null && $valor >= $this->muy_positivo) {
|
|
return 'muy_positivo';
|
|
}
|
|
if ($this->positivo !== null && $valor >= $this->positivo) {
|
|
return 'positivo';
|
|
}
|
|
if ($this->neutral !== null && $valor >= $this->neutral) {
|
|
return 'neutral';
|
|
}
|
|
if ($this->negativo !== null && $valor >= $this->negativo) {
|
|
return 'negativo';
|
|
}
|
|
return 'muy_negativo';
|
|
}
|
|
}
|