From 848f00cfdfcd7c75bc4ae72a15c80b4f3926075c Mon Sep 17 00:00:00 2001 From: nek0 Date: Thu, 9 Apr 2015 21:39:39 +0200 Subject: [PATCH] now added cash checks --- Handler/Journal.hs | 13 ++++++++++++- static/css/main.css | 4 ++++ templates/journal.hamlet | 19 +++++++++++++------ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Handler/Journal.hs b/Handler/Journal.hs index e7df105..4603a48 100644 --- a/Handler/Journal.hs +++ b/Handler/Journal.hs @@ -7,8 +7,19 @@ import Handler.Common getJournalR :: Handler Html getJournalR = do master <- getYesod - entries <- runDB $ selectList [] [Asc TransactionId] + 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.last $ entries + cashiers <- runDB $ selectList [CashierCreated <=. timeLimit] [Asc CashierId] + list <- return $ merge entries cashiers cashBalance <- getCashierBalance defaultLayout $ do $(widgetFile "journal") + +merge :: [Entity Transaction] -> [Entity Cashier] -> [Either Transaction Cashier] +merge [] [] = [] +merge (t:ts) [] = (Left $ entityVal t) : merge ts [] +merge (t:ts) (c:cs) + | transactionTime (entityVal t) < cashierCreated (entityVal c) = (Left $ entityVal t) : merge ts (c:cs) + | transactionTime (entityVal t) > cashierCreated (entityVal c) = (Right $ entityVal c) : merge (t:ts) cs diff --git a/static/css/main.css b/static/css/main.css index a7bfe67..53c3067 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -36,6 +36,10 @@ article#func.article { border-radius: 6px; } +tr#check { + background-color: lightgrey; +} + header { border-bottom: 1px solid black; margin-bottom: 1em; diff --git a/templates/journal.hamlet b/templates/journal.hamlet index d6a686e..bbc43c1 100644 --- a/templates/journal.hamlet +++ b/templates/journal.hamlet @@ -9,15 +9,22 @@ $if not $ L.null entries Zeit Beschreibung Betrag in #{appCurrency $ appSettings master} - $forall (Entity eId entry) <- entries - - #{formatTime defaultTimeLocale "%A %F %H:%M" $ transactionTime entry} - #{transactionDescription entry} - #{formatIntCurrency (transactionAmount entry)} #{appCurrency $ appSettings master} + $forall (eTransCash) <- list + $case eTransCash + $of Left trans + + #{formatTime defaultTimeLocale "%A %F %H:%M" $ transactionTime trans} + #{transactionDescription trans} + #{formatIntCurrency (transactionAmount trans)} #{appCurrency $ appSettings master} + $of Right cash + + + Kassensturz vom #{formatTime defaultTimeLocale "%A %F %H:%M" $ cashierCreated cash}: + #{formatIntCurrency (cashierBalance cash)} #{appCurrency $ appSettings master} Gesamtbetrag: - #{formatIntCurrency (fromIntegral total)} #{appCurrency $ appSettings master} + #{formatIntCurrency total} #{appCurrency $ appSettings master}

Kassenbestand: #{formatIntCurrency (fromIntegral cashBalance)} #{appCurrency $ appSettings master}