I am writing an accounting application. Generally, so far my design is as follows:
1. Account document. 2. Transaction document. It has kind of the usual structure... "debit", "credit", "qty", "value" etc. Here "debit" and "credit" are two account UUIDs I have a view with a reduce, that emits all the transactions for each account and calculates the account balance. Something quite similar to what is described here: http://books.couchdb.org/relax/receipts/banking The accounts are a tree structure. Every account can have child accounts. And transactions are only executed against accounts that have no children (leaf nodes). So far I have no problems in calculating the balance of the leaf nodes. Every node in the tree has a property called "lineage" that is a list with its "path" in the tree. So what I'm trying to do now is to calculate the balance of the branch nodes across the tree. One way is to do it client side (fetch all the leafs (view collation) that belong to some branch and calculate the balance in my application). This won't be a great problem, because I don't really believe that I'll have more than several hundred leafs altogether. Though I'm still interested to find out if there is some "cool" way to do it with couchdb.
