feat: mejorar gestión de seriales en entradas, salidas y transferencias de inventario
This commit is contained in:
parent
3384941cf5
commit
c7b28d9053
@ -211,8 +211,11 @@ public function bulkEntry(array $data): array
|
||||
'invoice_reference' => $data['invoice_reference'],
|
||||
]);
|
||||
|
||||
// Solo crear seriales si el producto los requiere (track_serials Y unidad sin decimales)
|
||||
$requiresSerials = $inventory->track_serials && ! $inventory->unitOfMeasure?->allows_decimals;
|
||||
|
||||
// Crear seriales DESPUÉS (para asignar movement_id)
|
||||
if (! empty($serialNumbers)) {
|
||||
if ($requiresSerials && ! empty($serialNumbers)) {
|
||||
$serials = [];
|
||||
foreach ($serialNumbers as $serialNumber) {
|
||||
$serials[] = [
|
||||
@ -239,7 +242,7 @@ public function bulkEntry(array $data): array
|
||||
$this->updateWarehouseStock($inventory->id, $warehouse->id, $quantity);
|
||||
}
|
||||
|
||||
$movements[] = $movement->load(['inventory', 'warehouseTo']);
|
||||
$movements[] = $movement->load(['inventory', 'warehouseTo', 'serials']);
|
||||
}
|
||||
|
||||
return $movements;
|
||||
@ -351,7 +354,7 @@ public function bulkExit(array $data): array
|
||||
]);
|
||||
}
|
||||
|
||||
$movements[] = $movement->load(['inventory', 'warehouseFrom']);
|
||||
$movements[] = $movement->load(['inventory', 'warehouseFrom', 'exitedSerials']);
|
||||
}
|
||||
|
||||
return $movements;
|
||||
@ -467,7 +470,7 @@ public function bulkTransfer(array $data): array
|
||||
]);
|
||||
}
|
||||
|
||||
$movements[] = $movement->load(['inventory', 'warehouseFrom', 'warehouseTo']);
|
||||
$movements[] = $movement->load(['inventory', 'warehouseFrom', 'warehouseTo', 'transferredSerials']);
|
||||
}
|
||||
|
||||
return $movements;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user