I have a design question. Hope this doesn't come across as a lazy attempt.
I'm writing a simple accounting application: A ledger has many accounts, each account has many transactions, and so on.
Double-entry accounting dictates we match transactions with other transactions, so I have a separate model called LedgerItemGroup, which has many transactions.
Very simplistically, we can consider a transaction matched if it belongs to a LedgerItemGroup and the sum of the totals of all transactions in that group is equal to zero.
So far, so good.
My question is what the best approach would be to design the edit_ledger_item view for an unmatched transaction so that the bookkeeper can manually match it with one or more other unmatched transactions.
Here's an (incomplete) layout of the models involved:
class LedgerAccount < ActiveRecord::Base
has_many :ledger_items
end
class LedgerItem < ActiveRecord::Base
belongs_to :ledger_account
belongs_to :ledger_item_group
def matched?
!self.ledger_item_group_id.nil?
end
end
class LedgerItemGroup < ActiveRecord::Base
has_many :ledger_items
def reconciled?
self.ledger_items.inject(0) { |sum, i| sum + i.total_amount } == 0
end
end
This seems to call for a string query input box, plus something to delimit the data range, which then would dynamically yield a list of possible matches. The bookkeeper than adds one or more to a cart of sorts. When checked out, this constitutes the LedgerItemGroup.
A simple multiple select box populated with a collection of unmatched transactions here is out of the question as we can easily have hundreds or thousands at hand.
I do not want to reinvent the wheel here. Is the best approach a checkout cart? Any pointers, suggestions would be appreciated.
The app itself is here should you wish to see more of the code.