better journal summary

This commit is contained in:
nek0 2015-04-10 17:00:50 +02:00
parent 1d19538a83
commit 6e2fef78f8

View file

@ -7,10 +7,12 @@ import Handler.Common
getJournalR :: Handler Html getJournalR :: Handler Html
getJournalR = do getJournalR = do
master <- getYesod master <- getYesod
rawEntries <- runDB $ selectList [] [Desc TransactionId, LimitTo 30] rawEntries <- runDB $ selectList [] [Desc TransactionId]
entries <- return $ L.reverse rawEntries entries <- return $ L.reverse $ L.take 30 rawEntries
total <- return $ L.sum $ I.map (transactionAmount . entityVal) entries total <- return $ L.sum $ I.map (transactionAmount . entityVal) rawEntries
timeLimit <- return $ transactionTime $ entityVal $ L.head $ entries timeLimit <- case L.null entries of
False -> return $ transactionTime $ entityVal $ L.head $ entries
True -> liftIO getCurrentTime
cashChecks <- runDB $ selectList [CashCheckTime >=. timeLimit] [Asc CashCheckId] cashChecks <- runDB $ selectList [CashCheckTime >=. timeLimit] [Asc CashCheckId]
list <- return $ merge entries cashChecks list <- return $ merge entries cashChecks
cashBalance <- getCashierBalance cashBalance <- getCashierBalance