up
This commit is contained in:
@@ -181,6 +181,10 @@ class OrdenProduccion extends Model
|
|||||||
{
|
{
|
||||||
if ($this->canBeFinalized()) {
|
if ($this->canBeFinalized()) {
|
||||||
$this->update(['estado' => 'finalizada']);
|
$this->update(['estado' => 'finalizada']);
|
||||||
|
|
||||||
|
// Crear inventario si corresponde
|
||||||
|
$this->crearInventarioPorFinalizacion();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -212,6 +216,13 @@ class OrdenProduccion extends Model
|
|||||||
|
|
||||||
// Si la orden llega a finalizada, crear entrada en inventario con lo que haya ingresado
|
// Si la orden llega a finalizada, crear entrada en inventario con lo que haya ingresado
|
||||||
if ($this->estado === 'finalizada') {
|
if ($this->estado === 'finalizada') {
|
||||||
|
$this->crearInventarioPorFinalizacion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function crearInventarioPorFinalizacion(): void
|
||||||
|
{
|
||||||
// Sumar procesos de acabados recibidos para determinar cantidad terminada
|
// Sumar procesos de acabados recibidos para determinar cantidad terminada
|
||||||
$cantidad = \App\Models\ProcesoAcabado::where('orden_produccion_id', $this->id)
|
$cantidad = \App\Models\ProcesoAcabado::where('orden_produccion_id', $this->id)
|
||||||
->whereNotNull('fecha_recepcion')
|
->whereNotNull('fecha_recepcion')
|
||||||
@@ -268,6 +279,4 @@ class OrdenProduccion extends Model
|
|||||||
// Si se creó inventario, también actualizar stock del producto asociado (handler en InventarioPrenda lo hará)
|
// Si se creó inventario, también actualizar stock del producto asociado (handler en InventarioPrenda lo hará)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
@foreach($ordersByState[$stateKey] as $op)
|
@foreach($ordersByState[$stateKey] as $op)
|
||||||
<div class="op-card bg-white rounded border p-2 shadow-sm" draggable="true" ondragstart="dragStart(event, {{ $op->id }})">
|
<div class="op-card bg-white rounded border p-2 shadow-sm" draggable="true" ondragstart="dragStart(event, {{ $op->id }})">
|
||||||
<div class="text-sm font-semibold">#{{ $op->numero_orden }} — {{ $op->prenda_modelo }}</div>
|
<div class="text-sm font-semibold">#{{ $op->numero_orden }} — {{ $op->prenda_modelo }}</div>
|
||||||
<div class="text-xs text-gray-500">Cant: {{ $op->cantidad_total }} · Metros: {{ $op->metros_requeridos }} · Entrega: {{ $op->fecha_entrega_estimada }}</div>
|
|
||||||
|
<div class="text-xs text-gray-500">
|
||||||
|
Cant: {{ $op->cantidad_total }} · Realizado: {{ $op->realizado }} · Faltan: {{ $op->faltantes }}<br>
|
||||||
|
Tela: {{ $op->tela?->codigo ?? '—' }} · Estado: <span class="inline-block px-2 py-0.5 rounded text-xs bg-gray-100">{{ \Illuminate\Support\Str::title(str_replace('_', ' ', $op->estado)) }}</span> · Entrega: {{ $op->fecha_entrega_estimada }}
|
||||||
|
</div>
|
||||||
<div class="mt-2 flex gap-2">
|
<div class="mt-2 flex gap-2">
|
||||||
<a href="{{ route('filament.admin.resources.orden-produccions.edit', ['record' => $op->id]) }}" class="text-blue-600 text-sm">Ver</a>
|
<a href="{{ route('filament.admin.resources.orden-produccions.edit', ['record' => $op->id]) }}" class="text-blue-600 text-sm">Ver</a>
|
||||||
<button class="text-sm px-2 py-1 bg-gray-100 rounded" onclick="quickAdvance({{ $op->id }})">Avanzar</button>
|
<button class="text-sm px-2 py-1 bg-gray-100 rounded" onclick="quickAdvance({{ $op->id }})">Avanzar</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user