From 5162e3fc19df2cb909dae85bebf44aba08738b23 Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Wed, 24 Jun 2020 02:05:25 +0200 Subject: [PATCH] Fix in stock calculation. closes #118 --- .../ecommerce/controller/shop/ShopArticleController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopArticleController.java b/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopArticleController.java index b1df109..9345e83 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopArticleController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/shop/ShopArticleController.java @@ -52,7 +52,11 @@ public class ShopArticleController { } model.addAttribute("article", article); - if (warehouseBookingPositionSlotEntryRepository.getByArticle(id).get(0).newSumSlot > 0) { //check if in Stock + if (warehouseBookingPositionSlotEntryRepository + .getByArticle(id) + .stream() + .mapToInt(e -> e.newSumSlot) + .sum() > 0) { //check if in Stock model.addAttribute("inStock", true); } else { model.addAttribute("inStock", false);