Permalink
Browse files

Fix guard for withdrawal

  • Loading branch information...
grahamrhay committed Apr 29, 2018
1 parent dec8480 commit ff572d3b20d99c18149fee38eebe9fc5a2db68db
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/bank_statem.erl
@@ -58,7 +58,7 @@ open({call, From}, place_hold, Data) ->
open({call, From}, {deposit, Amount}, Data) ->
handle_deposit(Amount, Data, From);
open({call, From}, {withdraw, Amount}, #{balance:=Balance} = Data) when is_number(Amount) andalso (Balance - Amount > 0) ->
open({call, From}, {withdraw, Amount}, #{balance:=Balance} = Data) when is_number(Amount) andalso (Balance - Amount >= 0) ->
NewBalance = Balance - Amount,
{keep_state, Data#{balance:=NewBalance}, [{reply, From, withdrawal_made}]}.

0 comments on commit ff572d3

Please sign in to comment.