Last active
December 2, 2019 05:12
-
-
Save justinhj/ee7e23443d0c00067c8e3b4332448cdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.onCommand[WithdrawCmd, WithdrawalResponse]{ | |
case (WithdrawCmd(time, description, amount), ctx, state) => | |
if(state.balance - amount >= 0) | |
ctx.thenPersist(WithdrawEvt(time, description, amount)){ _ => | |
ctx.reply(SuccessfulWithdrawalResponse(state.balance - amount)) | |
} | |
else { | |
ctx.reply(FailedWithdrawalResponse(s"Insufficient funds (current balance ${state.balance})")) | |
ctx.done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment