Module banking

Introduces bank accounts and transactions.

Functions

get_balance (owner) Gets the balance for a particular account
add_account (acc) Adds an account to the local cache
get_by_owner (owner) Gets account by owner name
transfer (actor, from, to, amount, reason) Transfers money between accounts, with permission checking

Tables

banking banking table

Class Account

Account:new (obj) Constructor
Account:to_table () Export to Lua table
Account:from_table (t) Import from Lua table
Account:withdraw (amount, to, reason) Withdraw from account
Account:deposit (amount, from, reason) Deposit into account


Functions

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

  1. nil
  2. string Error message

Tables

banking
banking table

Class Account

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
generated by LDoc 1.4.6 Last updated 2019-01-18 21:14:37