refactor(inventory): update stock validation rules and enforce stock_difference requirement

This commit is contained in:
2026-09-25 15:28:49 -03:00
parent 717f02ce16
commit a05d15d17f
13 changed files with 141 additions and 31 deletions

View File

@@ -141,8 +141,10 @@ class EntryService
$catalogItem->itemAttributes()
->whereHas('attribute', fn ($query) => $query->where('codigo', 'event_date'))
->update(['allow_multi_select' => true]);
$stockDifference = (int) ($entry['stock_difference'] ?? ((int) $entry['stock'] - $inventory->availableStock()));
$inventory->adjustAvailableStock($stockDifference, idempotencyKey: $stockAdjustmentId);
$inventory->adjustAvailableStock(
(int) $entry['stock_difference'],
idempotencyKey: $stockAdjustmentId,
);
return $catalogItem->load([
'variants.inventory',