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
+12 -12
View File
@@ -64,18 +64,6 @@ class Confeccion extends Model
}
});
/* Recepciones polimórficas */
public function recepciones()
{
return $this->morphMany(\App\Models\Recepcion::class, 'referencia');
}
// Cuantas faltan por recibir
public function getFaltantesAttribute()
{
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') {
@@ -83,4 +71,16 @@ class Confeccion extends Model
}
});
}
/* Recepciones polimórficas */
public function recepciones()
{
return $this->morphMany(\App\Models\Recepcion::class, 'referencia');
}
// Cuantas faltan por recibir
public function getFaltantesAttribute()
{
return max(0, (int)($this->cantidad_enviada ?? 0) - (int)($this->cantidad_recibida ?? 0));
}
}