accounts.hrl 1.0 KB

123456789101112131415161718192021222324252627
  1. -include("kvs.hrl").
  2. -type currency() :: internal | quota | game_points | money | bonus.
  3. -type account_id() :: {string(), currency()}. %% {username, currency}.
  4. -type transaction_id() :: string().
  5. -record(account, {
  6. id :: account_id(),
  7. debet = 0 :: integer(),
  8. credit = 0 :: integer(),
  9. last_change = 0 :: integer() }).
  10. -record(tx_payment,{ id :: integer() }).
  11. -record(tx_admin_change,{ reason :: binary() }).
  12. -record(tx_default_assignment,{ }).
  13. -type transaction_info() :: #tx_payment{} | #tx_admin_change{} | #tx_default_assignment{}.
  14. -record(user_transaction, {?CONTAINER, user}).
  15. -record(transaction, {?ITERATOR(user_transaction), %:: transaction_id(),
  16. commit_time :: erlang:now(),
  17. amount :: integer(), %% amount to move between accounts
  18. remitter :: account_id(), %% accout that gives money/points
  19. acceptor :: account_id(), %% account receive money/points
  20. currency :: currency(), %% some of the points or money
  21. info :: transaction_info()}).