This commit is contained in:
lizandrogd
2026-01-19 18:29:18 -05:00
parent 084b644714
commit eb95830bb3
3 changed files with 25 additions and 25 deletions
+8 -8
View File
@@ -64,6 +64,14 @@ class Confeccion extends Model
}
});
// Mantener avance de OP cuando la confección se completa
static::saved(function ($confeccion) {
if ($confeccion->estado === 'completo') {
$confeccion->ordenProduccion?->avanzarEstado();
}
});
}
/* Recepciones polimórficas */
public function recepciones()
{
@@ -75,12 +83,4 @@ class Confeccion extends Model
{
return max(0, (int)($this->cantidad_enviada ?? 0) - (int)($this->cantidad_recibida ?? 0));
}
// Mantener avance de OP cuando la confección se completa
static::saved(function ($confeccion) {
if ($confeccion->estado === 'completo') {
$confeccion->ordenProduccion?->avanzarEstado();
}
});
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ class Recepcion extends Model
if ($rec->referencia) {
$referencia = $rec->referencia;
$enviada = (int) ($referencia->cantidad_enviada ?? 0);
$yaRecibido = (int) \\App\\Models\\Recepcion::where('referencia_type', get_class($referencia))
$yaRecibido = (int) \App\Models\Recepcion::where('referencia_type', get_class($referencia))
->where('referencia_id', $referencia->id)
->sum('cantidad');
+8 -8
View File
@@ -55,6 +55,14 @@ class Tintoreria extends Model
}
});
// Avanzar OP al cerrar el paso o cuando se complete
static::saved(function ($tintoreria) {
if ($tintoreria->fecha_recepcion && $tintoreria->cantidad_recibida !== null) {
$tintoreria->ordenProduccion?->avanzarEstado();
}
});
}
/* Recepciones polimórficas */
public function recepciones()
{
@@ -66,12 +74,4 @@ class Tintoreria extends Model
{
return max(0, (int)($this->cantidad_enviada ?? 0) - (int)($this->cantidad_recibida ?? 0));
}
// Avanzar OP al cerrar el paso o cuando se complete
static::saved(function ($tintoreria) {
if ($tintoreria->fecha_recepcion && $tintoreria->cantidad_recibida !== null) {
$tintoreria->ordenProduccion?->avanzarEstado();
}
});
}
}