Module banking
Introduces bank accounts and transactions.
-
get_balance (owner)
-
Gets the balance for a particular account
Parameters:
Returns:
int
-
add_account (acc)
-
Adds an account to the local cache
Parameters:
-
get_by_owner (owner)
-
Gets account by owner name
Parameters:
Returns:
banking.Account
-
transfer (actor, from, to, amount, reason)
-
Transfers money between accounts, with permission checking
Parameters:
- actor
string
User requesting this transfer
- from
string
From account
- to
string
Target account
- amount
int
- reason
string
Transaction reason
Returns:
true
Or
-
nil
-
string
Error message
-
banking
-
banking table
Account Class which represents a bank account
-
Account:new (obj)
-
Constructor
Parameters:
- obj
A table to construct an object on top of
Returns:
banking.Account
-
Account:to_table ()
-
Export to Lua table
Returns:
table
-
Account:from_table (t)
-
Import from Lua table
Parameters:
Returns:
bool
true for success
-
Account:withdraw (amount, to, reason)
-
Withdraw from account
Parameters:
- amount
int
- to
string
target account
- reason
string
Transaction message
Returns:
bool
Returns false on failure
-
Account:deposit (amount, from, reason)
-
Deposit into account
Parameters:
- amount
int
- from
string
from account
- reason
string
Transaction message