From d1e48c82843011149de9d3a2f7259caafc373826 Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 5 Aug 2019 18:11:10 +0200 Subject: [PATCH] fix computation error for total bought products --- src/Model/Product.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Product.hs b/src/Model/Product.hs index 022e739..32024a1 100644 --- a/src/Model/Product.hs +++ b/src/Model/Product.hs @@ -26,7 +26,7 @@ import qualified Database.PostgreSQL.Simple as PGS import GHC.Generics -import Opaleye as O +import Opaleye as O hiding (max) import Opaleye.Constant as C -- internal imports @@ -183,7 +183,7 @@ productOverviewSelect conn = do i10 <- return $ snd $ foldl (\(bef, tot) (_, _, amo, _, ver) -> if ver then (amo, tot) - else (amo, tot + (bef - amo)) + else (amo, tot + max 0 (bef - amo)) ) (0, 0) (Prelude.reverse amounts)