restricting payout to available funds

This commit is contained in:
nek0 2017-10-19 17:11:33 +02:00
parent 851595911d
commit 7a2720f57e
2 changed files with 11 additions and 5 deletions

View file

@ -37,10 +37,16 @@ postPayoutR = do
$ renderBootstrap3 BootstrapBasicForm payoutForm $ renderBootstrap3 BootstrapBasicForm payoutForm
case res of case res of
FormSuccess payment -> do FormSuccess payment -> do
balance <- getCashierBalance
if balance >= payment
then
msg <- renderMessage' $ MsgPayout $ paymentDesc payment msg <- renderMessage' $ MsgPayout $ paymentDesc payment
updateCashier (- (paymentAmount payment)) msg updateCashier (- (paymentAmount payment)) msg
setMessageI MsgPaidOut setMessageI MsgPaidOut
redirect HomeR redirect HomeR
else
setMessageI MsgNotEnoughFunds
redirect HomeR
_ -> do _ -> do
setMessageI MsgNotPaidOut setMessageI MsgNotPaidOut
redirect JournalR redirect JournalR

View file

@ -1,5 +1,5 @@
name: yammat name: yammat
version: 0.0.7 version: 0.0.8
cabal-version: >= 1.8 cabal-version: >= 1.8
build-type: Simple build-type: Simple
license: AGPL-3 license: AGPL-3