[PROMOTE] 晉升 dev 變更至 demo 環境
1. [FIX] 補貨單完成邏輯與機台庫存去耦,防範重複累加 Bug 2. [FIX] 熱修復 Flatpickr 初始化中 Blade 大括號內不必要的反斜線轉義
This commit is contained in:
commit
4e0f4dd747
@ -1126,36 +1126,8 @@ class WarehouseController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// delivering → completed:增加機台貨道庫存並記錄異動
|
||||
// delivering → completed:更新完成時間(去耦機台庫存累加,由機台端上報決定)
|
||||
if ($newStatus === ReplenishmentOrder::STATUS_COMPLETED) {
|
||||
foreach ($replenishmentOrder->items as $item) {
|
||||
$slot = MachineSlot::where('machine_id', $replenishmentOrder->machine_id)
|
||||
->where('slot_no', $item->slot_no)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
|
||||
if ($slot) {
|
||||
$beforeQty = $slot->stock;
|
||||
$slot->increment('stock', $item->quantity);
|
||||
$slot->refresh();
|
||||
|
||||
MachineStockMovement::create([
|
||||
'company_id' => $replenishmentOrder->company_id,
|
||||
'machine_id' => $replenishmentOrder->machine_id,
|
||||
'product_id' => $item->product_id,
|
||||
'slot_no' => $item->slot_no,
|
||||
'type' => MachineStockMovement::TYPE_REPLENISHMENT,
|
||||
'quantity' => $item->quantity,
|
||||
'before_qty' => $beforeQty,
|
||||
'after_qty' => $slot->stock,
|
||||
'reference_type' => ReplenishmentOrder::class,
|
||||
'reference_id' => $replenishmentOrder->id,
|
||||
'note' => '補貨單完成入庫 #' . $replenishmentOrder->order_no,
|
||||
'created_by' => Auth::id(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$replenishmentOrder->completed_at = now();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user