You are here

Trade Worfklow, Refactoring for Transactions, No negative Balances

Submitted by greggles on Sat, 01/19/2008 - 14:15

I think I might drop "refactoring" from my descriptions because frankly small amounts of that are going to happen way to much to bother bringing up every time. But again, I did some ;)

Workflow States

I decided on the Workflow module which is simple to use, simple to setup and provides everything I need. It was particularly useful watching the video (available from the project homepage) .

More refactoring

So, I had a problem earlier about showing the points messages when a trade transaction had been rolled back and no trade had occurred. I got around it by storing the current site setting for showing messages, turning off messages, then doing my transaction, then setting it back to the original setting. The problem with this is that doing a variable_set forces a table LOCK which causes an autocommit so the transaction I created no longer mattered. Bummer. So, I had to put everything between the variable_set into a sub-function. No biggy, but it required a fair bit of testing. I am quite excited for Views to be updated to Drupal6 so I can start using Drupal6 (and Simpletest Automator to run automated regression tests.)

Negative Bank Accounts

While "loans" and "buying on margin" are possible in many environments, I didn't really want that to happen just yet. Since I'm using Userpoints I needed a module that used the hook_userpoints and the 'points before' event to check if the points would take a user negative and then block that. So, we now have a new module in Userpoints Contrib which will block users from going negative. There are some issues with the way it might interact with other modules like Userpoints basic, but I think it works well enough (I documented the potential pitfalls in the issue where the module was created).

There were a few other small fixes I made, but those were the biggies.

Next up on Todo:
1. Rename "contract group" to portfolio
2. Rename "contract" to something that is defined by admins
3. Do the actual book-making and trading of contracts!

Add new comment

Filtered HTML

  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <blockquote>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.