This commit is contained in:
Lizandro Guarnizo
2026-01-18 11:21:19 -05:00
parent 18c43fe06f
commit 33688d297c
21 changed files with 958 additions and 14 deletions
+25 -3
View File
@@ -32,8 +32,27 @@ class ProcesoAcabado extends Model
/* Lógica de negocio */
protected static function booted()
{
// Cuando se recibe el proceso
static::updated(function ($acabado) {
$createTrasladoFn = function ($acabado) {
if ($acabado->cantidad_recibida !== null) {
// Evitar duplicados
$exists = \App\Models\TrasladoPrenda::where('referencia_type', self::class)
->where('referencia_id', $acabado->id)
->exists();
if (! $exists) {
$destino = 'bodega';
\App\Models\TrasladoPrenda::crearDesdeReferencia(
$acabado,
'acabados',
$destino
);
// Avanzar la OP al cerrar este proceso
$acabado->ordenProduccion?->avanzarEstado();
}
}
if (
$acabado->fecha_recepcion &&
$acabado->cantidad_recibida !== null
@@ -49,6 +68,9 @@ class ProcesoAcabado extends Model
]);
}
}
});
};
static::updated($createTrasladoFn);
static::saved($createTrasladoFn);
}
}