yammat/Handler/CashCheck.hs

29 lines
797 B
Haskell
Raw Normal View History

2015-04-09 15:45:52 +00:00
module Handler.CashCheck where
import Import
import Handler.Common
getCashCheckR :: Handler Html
getCashCheckR = do
2015-04-10 12:50:44 +00:00
(cashCheckWidget, enctype) <- generateFormPost createCashCheckForm
2015-04-09 15:45:52 +00:00
defaultLayout $ do
$(widgetFile "cashCheck")
postCashCheckR :: Handler Html
postCashCheckR = do
2015-04-10 12:50:44 +00:00
((res, _), _) <- runFormPost createCashCheckForm
2015-04-09 15:45:52 +00:00
case res of
FormSuccess c -> do
runDB $ insert_ c
2015-04-10 12:50:44 +00:00
runDB $ insert_ $ Cashier (cashCheckBalance c)
2015-04-09 15:45:52 +00:00
setMessage "Kassensturz durchgeführt. Kasse aktualisiert"
redirect $ HomeR
_ -> do
setMessage "Fehler im Kassensturz"
redirect $ CashCheckR
2015-04-10 12:50:44 +00:00
createCashCheckForm :: Form CashCheck
createCashCheckForm = renderDivs $ CashCheck
2015-04-09 15:45:52 +00:00
<$> areq currencyField "Gezählter Betrag" Nothing
<*> lift (liftIO getCurrentTime)