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
msg <- renderMessage' $ MsgPayout $ paymentDesc payment balance <- getCashierBalance
updateCashier (- (paymentAmount payment)) msg if balance >= payment
setMessageI MsgPaidOut then
redirect HomeR msg <- renderMessage' $ MsgPayout $ paymentDesc payment
updateCashier (- (paymentAmount payment)) msg
setMessageI MsgPaidOut
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