fix(inventory): 修復倉庫低庫存警告計算與全站租戶名稱動態化
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 44s

This commit is contained in:
2026-02-02 11:03:09 +08:00
parent 1748eb007e
commit 75c634ffe4
8 changed files with 24 additions and 14 deletions

View File

@@ -37,6 +37,12 @@ class WarehouseController extends Controller
->orWhere('expiry_date', '>=', now());
});
}], 'quantity')
->addSelect(['low_stock_count' => function ($query) {
$query->selectRaw('count(*)')
->from('warehouse_product_safety_stocks as ss')
->whereColumn('ss.warehouse_id', 'warehouses.id')
->whereRaw('(SELECT COALESCE(SUM(quantity), 0) FROM inventories WHERE warehouse_id = ss.warehouse_id AND product_id = ss.product_id) < ss.safety_stock');
}])
->orderBy('created_at', 'desc')
->paginate(10)
->withQueryString();