up
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user