We are developing a system that will do financial statements and other financial-related things. We are developing the app in Java/Java EE, specifically in JBoss Seam (Richfaces, a4j) + Javascript and other technologies.
Now we have a lot or formulas to calculate the financial statement accounts. We need to build something that can be used to store formulas and use them in a simple way, or in a data structure so the formulas don’t kill the app with fixed numbers/references in all the code. (Maintainability concern.)
Now we have the formulas in a MS Excel sheet. There we have the common formulas from Excel (=A30+B40). Each row in excel is an account which we will store ultimately in a SQL server db table (account), but the main point here is how to storage/manage the formulas for a better use than hardcoded somewhere.
I know financial system do it, but I couldn’t find to much information about it.
If your primary concern is maintainability of formulas, I can think of two different approaches that might help.
Keep the formulas in Excel and use something like Apache POI to write values to the spreadsheet, then read back the evaluated formulas. (See http://poi.apache.org/spreadsheet/eval.html.) Not sure how well that scales or performs, but the distinct advantage is that if your client is constantly tweaking formulas in the Excel sheet, the changes take effect right away rather than constantly playing catch-up.
Translate the formulas into Java POJOs, but keep them all consolidated in a single class or package of pure business logic with no Java EE, Seam or JSF dependencies. Even though you’ll have to re-translate to Java every time the Excel version changes, at least it’s all in one place with a clear mapping between the original Excel source. You could also use a scripting language to let you change the formulas without a restart/redeploy cycle.