问题标签 [gaap]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
mongodb - Is there any way to use MapReduce to replay a sequential financial transaction log?
I'm working on a project that requires GAAP accounting conformance for deferred revenue collection. Cash is converted to a proprietary "currency" or credits. These credits may have different values based upon the purchase price at time of conversion (including exchange rate fluctuations).
As each purchase is made, the amount is deducted from the earliest "bucket" of credits until they are exhausted and the next eldest bucket is encountered. The valuation of the credits spent define the total revenue for that particular purchase... so it may differ for each product simply based upon the order of credits and debits / the value of each credit.
My sequential mind sees this as an easy imperative problem. With the data I'm capturing, I can replay the transaction logs and arrive at a daily total for revenue for each customer and each product... that can then be amortized for the services provided. No problem.
My data is in a sharded MongoDB cluster of replica sets. Dumping it and writing a post-processing script is easy, but I'd love to be able to report directly out of it.
I've played with simple MapReduce operations in the past. Is there any way to sequentially process a transaction log? While normal transaction logs can be processed in parallel, and I've done this, I just can't seem to find a way to twist MapReduce (MongoDB or Hadoop) to replay in order. I don't think it can be done. Am I wrong or just a n00b?
My only options at this point are post-processing replay, manipulating currency buckets at time of purchase or utilizing something I've overlooked... perhaps I'm not thinking enough outside the box here.
Any brief insights or pointers are greatly appreciated.