I'm experimenting with a new data model, inspired by ledger-cli and datamapper single table inheritance.
Take a look:
# Xact = transaction class Xact include DataMapper::Resource property :id,Serial property :posted_on,Integer property :memorandum,String has n, :assets has n, :liabilities has n, :equities has n, :expenses has n, :revenues has n, :banks end # Postings are the individual account changes class Posting include DataMapper::Resource property :id,Serial property :type,Discriminator property :xact_id,Integer property :commodity,String property :quantity,BigDecimal, :scale => 2, :precision => 5 belongs_to :xact end # Single table inheritance for every account class Asset < Posting; end class Liability < Posting; end class Equity < Posting; end class Revenue < Posting; end class Expense < Posting; end class Bank < Asset; end
The idea here is that each account is an object. The code above has the account types and then a bank account. This is obviously pre-alpha code, but the idea is there.
Its a big departure away from the way I've traditionally modeled accounting databases, so why bother?
I like this model because its super simple, and because it leverages some quality work that's already been done with datamapper, and it supports the sort of quick, instant reporting that is core to ledger-cli, especially the balance feature.
I'm interested in aligning Regdel with ledger to add to the traction its established. Open source accounting and bookkeeping software could use a little unity in my humble opinion. For awhile I felt that the single plain text file was a serious limitation, but those limitations might be alleviated with the combination of a SQLite and git, but that's a topic for another day.
Feedback about this new data model is much appreciated!
