now added cash checks

This commit is contained in:
nek0 2015-04-09 21:39:39 +02:00
parent d4609d1cbe
commit 848f00cfdf
3 changed files with 29 additions and 7 deletions

View file

@ -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

View file

@ -36,6 +36,10 @@ article#func.article {
border-radius: 6px;
}
tr#check {
background-color: lightgrey;
}
header {
border-bottom: 1px solid black;
margin-bottom: 1em;

View file

@ -9,15 +9,22 @@ $if not $ L.null entries
<th>Zeit
<th>Beschreibung
<th>Betrag in #{appCurrency $ appSettings master}
$forall (Entity eId entry) <- entries
$forall (eTransCash) <- list
$case eTransCash
$of Left trans
<tr>
<td>#{formatTime defaultTimeLocale "%A %F %H:%M" $ transactionTime entry}
<td>#{transactionDescription entry}
<td>#{formatIntCurrency (transactionAmount entry)} #{appCurrency $ appSettings master}
<td>#{formatTime defaultTimeLocale "%A %F %H:%M" $ transactionTime trans}
<td>#{transactionDescription trans}
<td>#{formatIntCurrency (transactionAmount trans)} #{appCurrency $ appSettings master}
$of Right cash
<tr #check>
<td colspan="2">
Kassensturz vom #{formatTime defaultTimeLocale "%A %F %H:%M" $ cashierCreated cash}:
<td>#{formatIntCurrency (cashierBalance cash)} #{appCurrency $ appSettings master}
<tfoot>
<tr>
<td colspan="2">Gesamtbetrag:
<td>#{formatIntCurrency (fromIntegral total)} #{appCurrency $ appSettings master}
<td>#{formatIntCurrency total} #{appCurrency $ appSettings master}
<p>
Kassenbestand: #{formatIntCurrency (fromIntegral cashBalance)} #{appCurrency $ appSettings master}