accounts.hrl 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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. %,top
  16. }).
  17. -record(transaction, {?ITERATOR(user_transaction),
  18. % id :: transaction_id(),
  19. commit_time :: erlang:now(),
  20. amount :: integer(), %% amount to move between accounts
  21. remitter :: account_id(), %% accout that gives money/points
  22. acceptor :: account_id(), %% account receive money/points
  23. currency :: currency(), %% some of the points or money
  24. info :: transaction_info()
  25. % next,
  26. % prev
  27. }).