views:

837

answers:

6

Back in October, Kristopher Johnson asked about Accounting Software Design Patterns

He received several answers, but they were all basically the same, pointing to Martin Fowlers Accounting Patterns.

I don't really find Fowlers patterns all that useful. They seem overly complex for a more simplistic accounting system, so I'm rehashing Kristopher's question and looking for more options, preferably for smaller systems.

This would be primarily a cash based system in which users are given accounts similar to a bank. They can log in (web based) and check balances, make certain transactions, etc..

I guess it would be more similar to a Paypal or Credit Card company than a bank, but on a smaller scale. It won't have to deal with taxes, or Amortizations, or any of the things you would see in a full fledged accounting system. Just balances, and transactions.

So can anyone point to any additional resources for accounting based software design or even good implementations of a simple accounting system?

A: 

Store money as cents (integer) instead of dollars (float). It's not a design but it's probably more useful.

Joe Philllips
I'm not currently concerned about implementation details. I want design patterns.
Mystere Man
+1  A: 

Google search for "two phase commit"

Not a design pattern per se but you need to make sure operations like "transfer $amount from $account1 to $account2" don't ever "withdraw" without the matching "deposit"... i.e. if the power goes out before the "deposit" completes, the "withdraw" is rolled back (undone)

Commit-able Transactions are made up of undo-able (rollback-able) sub-transactions...

  1. acquire permissions needed: trivial rejection, "insufficient funds"
  2. start a "two phase commit"
  3. add sub-transactions
  4. commit or roll-back

Warning: BCD math was invented to prevent round-off error in Base 10 math. You don't mention international issues, but you'd need fixed-point or "large precision" math, currency conversion, and all the rest...

reechard
+6  A: 

Fowler's patterns are not overly complex. They are about what is needed. You are unlikely to be able to build something simpler without getting in trouble with either the end users or the accountant.

Stephan Eggermont
+3  A: 

So can anyone point to any additional resources for accounting based software design or even good implementations of a simple accounting system?

The Free Digital Money Project looks helpful for your needs. It provides a basic transaction and balance framework. It is intentionally simple and abstract, so may offer useful design insights, particularly if you want to test novel ideas.

Cyclos is more practical. It covers user accounts and transactions.

MyBanco is another open source banking system, supporting user bank accounts and web-based access. It can be used with both virtual and real currencies.

All of these are open source so you can check out the docs, architecture and code directly.

As an aside, if you are really only interested in balances and transactions, then it sounds like any pattern or project related to reputation, karma, or points systems will likely have relevant overlap...

ire_and_curses
MyBanco is php nonsense
Stephan Eggermont
Good Examples. I'll check them out, thanks.
Mystere Man
+3  A: 

When I implement accounting it's the typical model of a journals, transactions and accounts and account types.

tblTransactions
    - Amount
    - AccountID1
    - AccountID2
    - Type [CR/DR]
    - DateEntered

I then also have a tblJournals which groups transactions on the obvious basis. You may also add JournalTypes, which hold a general description of what sort of journal it is, so you can detect nice things (reverals, etc).

It's nice, because reversals under this model are trivial. You can just gather all the transactions for your journal, and swap the type.

The tblTransactions has a trigger, and the trigger updates a 'CalculatedBalance' against the specific accounts depending on the type. You can then also run a report over a given period, and so on.

It doesn't require much accounting knowledge to implement this and is simple, yet effective.

Noon Silk
I have almost zero accounting knowledge, so even "journals" are a foreign concept to me. I understand what a journal is in software, typically a fileysystem (a transaction log that can get replayed in the event of a failure)... I assume a journal has some analogue to this.
Mystere Man
A journal is just a pointer at a series of transactions, with some additional information. So it may contain the date, a description, and the 'type'. The type refers to what all the underlying transactions are doing. Refund, whatever (you can make it up in the context of your system). You map them via a table like 'tblJournalTransactions' (many transactions to one journal).
Noon Silk
+1  A: 

I am actually the author of MyBanco, if you would like any help, just drop me an email :)

Tim G