up
This commit is contained in:
@@ -104,7 +104,19 @@ class ConfeccionResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\Placeholder::make('recepcion_summary')
|
||||
->label('Resumen')
|
||||
->content(fn ($get) => "Total recibido: " . ($get('cantidad_recibida') ?? 0) . " — Faltan: " . ($get('faltantes') ?? 0)),
|
||||
->content(function ($get) {
|
||||
$id = $get('id');
|
||||
if (! $id) return 'Sin recepciones registradas';
|
||||
|
||||
$total = \App\Models\Recepcion::where('referencia_type', \App\Models\Confeccion::class)
|
||||
->where('referencia_id', $id)
|
||||
->sum('cantidad');
|
||||
|
||||
$enviada = (int) ($get('cantidad_enviada') ?? 0);
|
||||
$faltan = max(0, $enviada - $total);
|
||||
|
||||
return "Total recibido: {$total} — Faltan: {$faltan}";
|
||||
}),
|
||||
|
||||
Forms\Components\Placeholder::make('instrucciones')
|
||||
->label('Acciones')
|
||||
|
||||
@@ -78,9 +78,15 @@ class Confeccion extends Model
|
||||
return $this->morphMany(\App\Models\Recepcion::class, 'referencia');
|
||||
}
|
||||
|
||||
// Cuantas faltan por recibir
|
||||
// Total recibido calculado desde recepciones (fuente de la verdad)
|
||||
public function getRecibidoTotalAttribute()
|
||||
{
|
||||
return (int) $this->recepciones()->sum('cantidad');
|
||||
}
|
||||
|
||||
// Cuantas faltan por recibir (usa la suma real de recepciones)
|
||||
public function getFaltantesAttribute()
|
||||
{
|
||||
return max(0, (int)($this->cantidad_enviada ?? 0) - (int)($this->cantidad_recibida ?? 0));
|
||||
return max(0, (int)($this->cantidad_enviada ?? 0) - $this->recibido_total);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,15 @@ class Tintoreria extends Model
|
||||
return $this->morphMany(\App\Models\Recepcion::class, 'referencia');
|
||||
}
|
||||
|
||||
// Cuantas faltan por recibir
|
||||
// Total recibido calculado desde recepciones (fuente de la verdad)
|
||||
public function getRecibidoTotalAttribute()
|
||||
{
|
||||
return (int) $this->recepciones()->sum('cantidad');
|
||||
}
|
||||
|
||||
// Cuantas faltan por recibir (usa la suma real de recepciones)
|
||||
public function getFaltantesAttribute()
|
||||
{
|
||||
return max(0, (int)($this->cantidad_enviada ?? 0) - (int)($this->cantidad_recibida ?? 0));
|
||||
return max(0, (int)($this->cantidad_enviada ?? 0) - $this->recibido_total);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user