title: Custom Rules -- how to implement in web-based tool?
body: <p>So I am building a web based replacement for a forecasting tool built using excel.</p>
  
  <p>For the most part, the line items are simple -- X units of Y, at unit cost Z equals this line item cost.</p>
  
  <p>However, for an unavoidable handful of types of items, the rules are more complex (two types of items taken together, integer divided by six, times a cost item, to get one -- etc.). Ultimately, these rules may change over time -- in fact one of the goals of redoing the tool is to make it easy for finance to "tweak" the formulas.</p>
  
  <p>So here's my question: is there an architecture or design pattern best suited to this? I could store "rules" as javascript that I eval to do calculations, but this seems hacky and insecure. However, I can't come up with a better solution that allows some "free form" logic in a basically sandboxed environment.</p>
  
  <p>Keep in mind that this is (right now) a very small tool, so buying some big, expensive business intelligence tool is a non-starter. </p>