Monday, April 12, 2010

Render financial statements into graphs

One of our customers required a visualization of the financial data generated by the system to make it easier for top management to see the trends and indications from the data.
We decided to render the output of the financial statement reports into a spreadsheet activex control similar to that of the "Graph of balance" which could be found in the chart of accounts details form (Balance --> Graph of balance).

Our approach goes as follows:
  1. Add a new output type to the financial statement.
  2. Create a new form that displays the graph generated by the rendering class.
  3. Create a class that performs the rendering.
  4. Modify the LedgerBalanceSheetDimPrint class so that the new form is called when the chosen output type is "Graph".
Adding a new output type

This is simply done by adding a new element to the BaseEnum that appears in the form (namely, DimensionsOutputType).

Form to display the generated graph

You can duplicate the "Graph of balance" form, or if you're comfortable with using the Graphics class then you can create a new form. The whole sotry lies in the loadData method of the graph object that you create. You can choose whether columns should be on the XAxis and rows on the YAxis or vice versa (it is even better to parameterize this option) in a way such that financial statment column labels and row labels are used as axis labels (make sure to truncate the names because they are too long and would impair the display of the graph).

Class to manage the graph rendering

We have created a new class similar to LedgerBalanceSheetDimFile (the class used to export the financial statement into files). This way it becomes easier to manage the output of the graph in terms of graph options with relation to the financial statement parameters (which column goes to which axis, what type of graph ... etc.).

Modify the LedgerBalanceSheetDimPrint class

This is where everything starts. However, the changes that need to be made here are minimal (which is very convenient in the case of an upgrade). The changes that will be made to this class occur in the run method and a new method to call the form that displays the graph.

In the run method add a new case to the switch statement that decides what output type has the user chosen for the financial statement.



The runGraph method should be similar to the runReport method the only difference being that it calls a form instead of a report.


Now, your financial statement is ready to display a simple financial statement in nice looking graph.



Please follow this link for the code sample

No comments:

Post a Comment