- 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>
56 lines
1.3 KiB
PHP
56 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;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Reporte extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'cliente_id',
|
|
'nombre',
|
|
'periodo_tipo',
|
|
'periodo_inicio',
|
|
'periodo_fin',
|
|
'fecha_generacion',
|
|
'data_calculada',
|
|
'pdf_path',
|
|
'status',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'periodo_inicio' => 'date',
|
|
'periodo_fin' => 'date',
|
|
'fecha_generacion' => 'datetime',
|
|
'data_calculada' => 'array',
|
|
];
|
|
}
|
|
|
|
public function cliente(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Cliente::class);
|
|
}
|
|
|
|
public function balanzas(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Balanza::class, 'reporte_balanza');
|
|
}
|
|
|
|
public function getMetrica(string $nombre): ?array
|
|
{
|
|
return $this->data_calculada['metricas'][$nombre] ?? null;
|
|
}
|
|
|
|
public function getEstadoFinanciero(string $tipo): ?array
|
|
{
|
|
return $this->data_calculada['estados_financieros'][$tipo] ?? null;
|
|
}
|
|
}
|