diff --git a/src/Service/DrinkType/GetStockHistory.php b/src/Service/DrinkType/GetStockHistory.php index a9f34c1..3704887 100644 --- a/src/Service/DrinkType/GetStockHistory.php +++ b/src/Service/DrinkType/GetStockHistory.php @@ -23,10 +23,18 @@ final readonly class GetStockHistory if ($drinkType->getId() === null) { return[]; } - return $this->propertyChangeLogRepository->findBy([ + $items = $this->propertyChangeLogRepository->findBy([ 'entityClass' => DrinkType::class, 'propertyName' => 'currentStock', 'entityId' => $drinkType->getId(), ]); + $currentStock = new PropertyChangeLog(); + $currentStock->setNewValue((string) $drinkType->getCurrentStock()); + $currentStock->setEntityClass(DrinkType::class); + $currentStock->setEntityId($drinkType->getId()); + $currentStock->setPropertyName('currentStock'); + + $items[] = $currentStock; + return $items; } } diff --git a/src/Service/DrinkType/GetWantedHistory.php b/src/Service/DrinkType/GetWantedHistory.php index 9e1533b..c3b0796 100644 --- a/src/Service/DrinkType/GetWantedHistory.php +++ b/src/Service/DrinkType/GetWantedHistory.php @@ -18,10 +18,17 @@ final readonly class GetWantedHistory return[]; } - return $this->propertyChangeLogRepository->findBy([ + $items = $this->propertyChangeLogRepository->findBy([ 'entityClass' => DrinkType::class, 'propertyName' => 'wantedStock', 'entityId' => $drinkType->getId(), ]); + $wantedStock = new PropertyChangeLog(); + $wantedStock->setNewValue((string) $drinkType->getWantedStock()); + $wantedStock->setEntityClass(DrinkType::class); + $wantedStock->setEntityId($drinkType->getId()); + $wantedStock->setPropertyName('wantedStock'); + $items[] = $wantedStock; + return $items; } } diff --git a/templates/components/history_chart.html.twig b/templates/components/history_chart.html.twig new file mode 100644 index 0000000..a6f6a0d --- /dev/null +++ b/templates/components/history_chart.html.twig @@ -0,0 +1,71 @@ +{# + History Chart Component + + Parameters: + - stock_history: Array of stock history records with changeDate and newValue properties + - wanted_history: Array of wanted stock history records with newValue properties + - chart_id: ID for the canvas element (default: 'stockHistoryChart') + - title: Title for the chart card (default: 'History') +#} + +{% set chart_id = chart_id|default('stockHistoryChart') %} +{% set title = title|default('History') %} + +