commit14
This commit is contained in:
@@ -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.']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user