Refresh stock forecast after each sale
This commit is contained in:
1 parent
5dd41a4bb2
commit
03ea914d04
3 files changed
+76
-21
No files matched your search
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/forecast.php';
|
||||
|
||||
function get_default_location_ids(PDO $pdo): array
|
||||
{
|
||||
$row = $pdo->query(
|
||||
@@ -530,8 +532,10 @@ function allocate_components_for_line(
|
||||
|
||||
$allocationCount = 0;
|
||||
$virtualAllocationCount = 0;
|
||||
$forecastProductIds = [];
|
||||
foreach ($components as $component) {
|
||||
$productId = (int) $component['product_id'];
|
||||
$forecastProductIds[$productId] = true;
|
||||
$remaining = $lineQty * (float) $component['qty_per_item'];
|
||||
$guard = 0;
|
||||
|
||||
@@ -587,6 +591,10 @@ function allocate_components_for_line(
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_keys($forecastProductIds) as $productId) {
|
||||
refresh_lager_stock_lot_forecast_for_product($pdo, (int) $productId);
|
||||
}
|
||||
|
||||
return [
|
||||
'allocated' => true,
|
||||
'allocationCount' => $allocationCount,
|
||||
|
||||
Reference in new issue
Block a user