From 6e2fef78f89df3901129b441a78bfc474a53b9da Mon Sep 17 00:00:00 2001 From: nek0 Date: Fri, 10 Apr 2015 17:00:50 +0200 Subject: [PATCH] better journal summary --- Handler/Journal.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Handler/Journal.hs b/Handler/Journal.hs index 557d0cb..341a76a 100644 --- a/Handler/Journal.hs +++ b/Handler/Journal.hs @@ -7,10 +7,12 @@ import Handler.Common getJournalR :: Handler Html getJournalR = do master <- getYesod - rawEntries <- runDB $ selectList [] [Desc TransactionId, LimitTo 30] - entries <- return $ L.reverse rawEntries - total <- return $ L.sum $ I.map (transactionAmount . entityVal) entries - timeLimit <- return $ transactionTime $ entityVal $ L.head $ entries + rawEntries <- runDB $ selectList [] [Desc TransactionId] + entries <- return $ L.reverse $ L.take 30 rawEntries + total <- return $ L.sum $ I.map (transactionAmount . entityVal) rawEntries + timeLimit <- case L.null entries of + False -> return $ transactionTime $ entityVal $ L.head $ entries + True -> liftIO getCurrentTime cashChecks <- runDB $ selectList [CashCheckTime >=. timeLimit] [Asc CashCheckId] list <- return $ merge entries cashChecks cashBalance <- getCashierBalance