存储公式来计算财务报告的有效方法?

发布于 2024-12-23 13:56:20 字数 420 浏览 4 评论 0原文

我们正在开发一个系统,可以处理财务报表和其他与财务相关的事情。我们正在使用 Java/Java EE 开发应用程序,特别是使用 JBoss Seam(Richfaces、a4j)+ Javascript 和其他技术。

现在我们有很多或公式来计算财务报表科目。我们需要构建一些可用于存储公式并以简单的方式或在数据结构中使用它们的东西,这样公式就不会在所有代码中使用固定数字/引用来杀死应用程序。 (可维护性问题。)

现在我们在 MS Excel 工作表中拥有了公式。这里有 Excel 中的常用公式 (=A30+B40)。 Excel 中的每一行都是一个帐户,我们最终将其存储在 SQL Server 数据库表中(account),但这里的要点是如何存储/管理公式,以便比在某处硬编码更好地使用公式。

我知道金融系统会这样做,但我找不到太多有关它的信息。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

以可爱出名 2024-12-30 13:56:20

如果您主要关心的是公式的可维护性,我可以想到两种可能有所帮助的不同方法。

  • 将公式保留在 Excel 中,并使用 Apache POI 之类的工具将值写入电子表格,然后读回计算后的公式。 (请参阅http://poi.apache.org/spreadsheet/eval.html。)不确定其扩展或执行效果如何,但明显的优势是,如果您的客户不断调整 Excel 工作表中的公式,则更改会立即生效,而不是不断追赶。

  • 将公式转换为 Java POJO,但将它们全部整合到单个类或纯业务逻辑包中,不依赖于 Java EE、Seam 或 JSF。尽管每次 Excel 版本更改时您都必须重新转换为 Java,但至少一切都集中在一个位置,并且原始 Excel 源之间有清晰的映射。您还可以使用脚本语言来更改公式,而无需重新启动/重新部署周期。

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.

清音悠歌 2024-12-30 13:56:20

我们曾经做过类似的事情,将 KPI 公式存储在 SQL 表中。我们的 C 程序将从表中读取并运行 SQL。

我们的 KPI 对影响统计的各种因素进行加权。这样,我们就可以更改权重和公式(添加或删除因子),而无需更改程序。

We did something similiar once where we stored KPI formulas in a SQL table. Our C program would read and run the SQL from the table.

Our KPIs uses weighting on the various factors contributing to the statistic. This way, we could change the weighting and formula (adding or removing factors) without having to change the program.

向地狱狂奔 2024-12-30 13:56:20

这听起来像是一个很棒的函数应用程序,无论是在应用程序代码中还是作为 sql 函数。我强烈建议将函数存储在 java 代码中,而不是存储在 sql 中,因为它更容易测试和更改。诚然,嵌入式 sql 函数可以执行得更好,并且可以批量执行,但性能并不是一切,当您调试或更改它们时您就会知道。

It sounds like a great application for a function, either in your application code, or as a sql function. I would highly recommend storing your functions in java code vs. sql as it is much easier to test and change. True, embedded sql functions can perform better and can executed in batch but performance is not everything as you will know when you will debug or change them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文