8a525a1088
Conflicts: Handler/CashCheck.hs Handler/NewUser.hs templates/journal.hamlet templates/modify.hamlet
29 lines
832 B
Haskell
29 lines
832 B
Haskell
module Handler.CashCheck where
|
|
|
|
import Import
|
|
import Handler.Common
|
|
|
|
getCashCheckR :: Handler Html
|
|
getCashCheckR = do
|
|
(cashCheckWidget, enctype) <- generateFormPost createCashCheckForm
|
|
defaultLayout $ do
|
|
$(widgetFile "cashCheck")
|
|
|
|
postCashCheckR :: Handler Html
|
|
postCashCheckR = do
|
|
((res, _), _) <- runFormPost createCashCheckForm
|
|
case res of
|
|
FormSuccess c -> do
|
|
currentTime <- liftIO getCurrentTime
|
|
runDB $ insert_ c
|
|
runDB $ insert_ $ Cashier (cashCheckBalance c) currentTime
|
|
setMessageI MsgCashChecked
|
|
redirect $ HomeR
|
|
_ -> do
|
|
setMessageI MsgCashCheckError
|
|
redirect $ CashCheckR
|
|
|
|
createCashCheckForm :: Form CashCheck
|
|
createCashCheckForm = renderDivs $ CashCheck
|
|
<$> areq currencyField (fieldSettingsLabel MsgCountedValue) Nothing
|
|
<*> lift (liftIO getCurrentTime)
|