This commit is contained in:
2026-11-02 20:27:11 +02:00
parent b44378b899
commit badaada043
300 changed files with 17458 additions and 1056 deletions
+3 -3
View File
@@ -18,7 +18,7 @@ class WarehouseReservations
public function committed(int $item, int $warehouse): int
{
return $this->ready() ? (int) DB::table('warehouse_reservations')->where('tenant_id', auth()->user()?->tenant_id)->where('stock_item_id', $item)->where('warehouse_id', $warehouse)->sum('quantity_milli') : 0;
return $this->ready() ? (int) DB::table('warehouse_reservations')->where('tenant_id', auth()->user()?->tenant_id ?? app(ReplenishmentRun::class)->tenantId())->where('stock_item_id', $item)->where('warehouse_id', $warehouse)->sum('quantity_milli') : 0;
}
/** @return array<int,int> */
@@ -114,10 +114,10 @@ class WarehouseReservations
/** Refuse worsening a shortage of usable reserved material; quality holds remain independent. */
public function protect(int $item, int $warehouse, int $before): void
{
if (! $this->ready() || $this->committed($item,$warehouse) === 0) {
if (! $this->ready() || $this->committed($item, $warehouse) === 0) {
return;
}
if ($this->free($item,$warehouse) < min(0,$before)) {
if ($this->free($item, $warehouse) < min(0, $before)) {
throw ValidationException::withMessages(['quantity' => 'Esta operação consumiria material reservado. Liberte ou regularize a reserva autorizadamente.']);
}
}