From cc5661146ca5da180c86f5fe3e1ce3dfe3148390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Gla=CC=88ser?= Date: Sun, 6 Sep 2026 08:56:50 +0200 Subject: [PATCH] Expose per-product forecast errors --- .../processes/main/erp.lager.stock_lot_forecast_refresh.md | 3 ++- modules/erp/lager/forecast.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/modules/erp/lager/processes/main/erp.lager.stock_lot_forecast_refresh.md b/docs/modules/erp/lager/processes/main/erp.lager.stock_lot_forecast_refresh.md index ba8848a..640927d 100644 --- a/docs/modules/erp/lager/processes/main/erp.lager.stock_lot_forecast_refresh.md +++ b/docs/modules/erp/lager/processes/main/erp.lager.stock_lot_forecast_refresh.md @@ -82,7 +82,8 @@ Nicht erforderlich. Die Produktmenge ist klein; die Verarbeitung erfolgt determi "total_products": 0, "processed_products": 0, "failed_products": 0, - "failed_product_ids": [] + "failed_product_ids": [], + "errors": [{"product_id": 0, "message": "..."}] } ``` diff --git a/modules/erp/lager/forecast.php b/modules/erp/lager/forecast.php index f7daa04..6030786 100644 --- a/modules/erp/lager/forecast.php +++ b/modules/erp/lager/forecast.php @@ -187,7 +187,7 @@ function run_lager_stock_lot_forecast(PDO $pdo): array $asOfDate = new DateTimeImmutable('today', new DateTimeZone('Europe/Zurich')); $result = [ 'status' => 'done', 'total_products' => 0, 'processed_products' => 0, - 'failed_products' => 0, 'failed_product_ids' => [], + 'failed_products' => 0, 'failed_product_ids' => [], 'errors' => [], ]; try { @@ -208,6 +208,7 @@ function run_lager_stock_lot_forecast(PDO $pdo): array } catch (Throwable $error) { $result['failed_products']++; $result['failed_product_ids'][] = $productId; + $result['errors'][] = ['product_id' => $productId, 'message' => $error->getMessage()]; } } if ($result['failed_products'] > 0) {