now capable of holding more than one cashier
This commit is contained in:
parent
cd782faacb
commit
c625d65c41
6 changed files with 16 additions and 7 deletions
|
@ -34,6 +34,7 @@ import Handler.Journal
|
|||
import Handler.Payout
|
||||
import Handler.Summary
|
||||
import Handler.Modify
|
||||
import Handler.CashCheck
|
||||
|
||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
||||
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||
|
|
|
@ -26,19 +26,20 @@ getRobotsR = return $ TypedContent typePlain
|
|||
|
||||
updateCashier :: Int -> Text -> Handler ()
|
||||
updateCashier amount desc = do
|
||||
mCashier <- runDB $ selectFirst [] [Asc CashierId]
|
||||
mCashier <- runDB $ selectFirst [] [Desc CashierCreated]
|
||||
trans <- liftIO $ (\time -> return $ Transaction desc amount time) =<< getCurrentTime
|
||||
case mCashier of
|
||||
Just entCash -> do
|
||||
runDB $ update (entityKey entCash) [CashierBalance +=. amount]
|
||||
runDB $ insert_ trans
|
||||
Nothing -> do
|
||||
runDB $ insert_ $ Cashier amount
|
||||
currentTime <- liftIO getCurrentTime
|
||||
runDB $ insert_ $ Cashier amount currentTime
|
||||
runDB $ insert_ trans
|
||||
|
||||
getCashierBalance :: Handler Int
|
||||
getCashierBalance = do
|
||||
mCashier <- runDB $ selectFirst [] [Asc CashierId]
|
||||
mCashier <- runDB $ selectFirst [] [Desc CashierCreated]
|
||||
case mCashier of
|
||||
Just cashier -> do
|
||||
return $ cashierBalance $ entityVal cashier
|
||||
|
|
|
@ -20,6 +20,7 @@ Transaction
|
|||
deriving Typeable Show
|
||||
Cashier
|
||||
balance Int
|
||||
created UTCTime default=now()
|
||||
deriving Typeable Show
|
||||
|
||||
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
|
||||
|
|
|
@ -21,3 +21,4 @@
|
|||
/summary SummaryR GET
|
||||
/modify/#BeverageId ModifyR GET POST
|
||||
/delete/#BeverageId DeleteBeverageR GET
|
||||
/cashcheck CashCheckR GET POST
|
||||
|
|
|
@ -21,8 +21,12 @@ $if not $ L.null entries
|
|||
<p>
|
||||
Kassenbestand: #{formatIntCurrency (fromIntegral cashBalance)} #{appCurrency $ appSettings master}
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href=@{PayoutR}>
|
||||
Aus der Kasse auszahlen
|
||||
<li>
|
||||
<a href=@{CashCheckR}>
|
||||
Kassensturz
|
||||
$else
|
||||
<p>Noch keine Bewegungen zu verzeichnen
|
||||
|
|
|
@ -29,6 +29,7 @@ library
|
|||
Handler.Payout
|
||||
Handler.Summary
|
||||
Handler.Modify
|
||||
Handler.CashCheck
|
||||
|
||||
if flag(dev) || flag(library-only)
|
||||
cpp-options: -DDEVELOPMENT
|
||||
|
|
Loading…
Reference in a new issue