Files
2019-12-17 07:25:03 +11:00

19 lines
447 B
Go

package commands
import "github.com/wahyd4/cash/domains"
// WithdrawCommand the command for withdrawing some money
type WithdrawCommand struct {
Account string
Money float64
}
// Run withdraws money from the bank, returns error if fails
func (command *WithdrawCommand) Run(bank *domains.Bank) error {
account, err := bank.AccountFromName(command.Account)
if err != nil {
return err
}
return bank.WithdrawFor(account, command.Money)
}