up
This commit is contained in:
+12
-12
@@ -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
|
// Mantener avance de OP cuando la confección se completa
|
||||||
static::saved(function ($confeccion) {
|
static::saved(function ($confeccion) {
|
||||||
if ($confeccion->estado === 'completo') {
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class Recepcion extends Model
|
|||||||
if ($rec->referencia) {
|
if ($rec->referencia) {
|
||||||
$referencia = $rec->referencia;
|
$referencia = $rec->referencia;
|
||||||
$enviada = (int) ($referencia->cantidad_enviada ?? 0);
|
$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)
|
->where('referencia_id', $referencia->id)
|
||||||
->sum('cantidad');
|
->sum('cantidad');
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -55,18 +55,6 @@ class Tintoreria 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Avanzar OP al cerrar el paso o cuando se complete
|
// Avanzar OP al cerrar el paso o cuando se complete
|
||||||
static::saved(function ($tintoreria) {
|
static::saved(function ($tintoreria) {
|
||||||
if ($tintoreria->fecha_recepcion && $tintoreria->cantidad_recibida !== null) {
|
if ($tintoreria->fecha_recepcion && $tintoreria->cantidad_recibida !== null) {
|
||||||
@@ -74,4 +62,16 @@ class Tintoreria 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user