IReport on a Mac

From MTHWiki

(Difference between revisions)
Jump to: navigation, search
(iReport on Mac)
Line 144: Line 144:
Please note that if you re-install MyMoney you will lose all custom reports installed in MyMoneys system areas, so please keep a backup.
Please note that if you re-install MyMoney you will lose all custom reports installed in MyMoneys system areas, so please keep a backup.
-
We are planning to add a User Report folder in future versions of MyMoney and Portfolio Analyst.
+
 
 +
=== Persisting User Defined Report ===
 +
 
 +
MyMoney has a special location for user-defined reports. If you place your report there it will not disappear if you reinstall or upgrade MyMoney.
 +
 
 +
The location of this folder changes depending on the system and operating permissions. The easiest way to locate it is
 +
to start MyMoney, use View-Show console menu and type the following command in the console - <pre>print(SwingMoneyView.singleInstance.environment.getUserApplicationHome());</pre>
 +
 
 +
Please note the output, this is where your user data is written to, for example it could be <pre>/Users/xxx/Library/Containers/com.mth.money/Data/Library/.mymoney</pre>
 +
 
 +
Once you located this folder you need to create a report folder within it, to do so please open a Finder window and use Go-Go to folder to navigate to the user data (/Users/xxx/Library/Containers/com.mth.money/Data/Library/.mymoney)
 +
 
 +
While in user data folder please change to system, if you don't have a 'reports' folder please create it, and then please create 'user'folder so your structure looks like /Users/xxx/Library/Containers/com.mth.money/Data/Library/.mymoney/system/reports/user
 +
 
 +
Please copy your reports into this '''system/reports/user''' folder
 +
 
 +
Please start MyMoney.app, switch to Reports folder - if you did everything correctly you will see User Reports section that will contain your newly copied report. If you update MyMoney in the future your User defined report will survive

Revision as of 00:37, 13 January 2014

Contents

Introduction

My Money is using JasperReports as its Reporting engine. Jasper is open sourced, actively developed, has a large community of users and is generally generally well understood (wikipedia) piece of software code. We at MTH Software like it and trust it enough to embed it into our own software.

To actually design a report for My Money you need a front-end software for Jasper reports, there is a bunch of 3rd party tools we prefer iReport, it is free, relatively fast and seems to be bug free.


iReport on Mac

Please download iReport for Mac, you can get it from JasperForge, please get the version 4.0 (if it isn't available on JasperForge you can also download it from our servers directly - iReport-4.0.0.dmg )


Before starting to use iReport please create a folder on your system where you will be keeping your custom reports, for the purposes of this article lets call it CustomReports .

Please locate MyMoney on your system (it will most likely reside in Applications folder) and right click on it to see "Show Package Contents" menu. Please navigate inside of the package and copy a system report that you would like to edit, for example to edit report that categorizes transactions please locate categorized_p100.jrxml under Contents/Resources/system/reports/built-in

Please also copy report syles file called styles.jrtx

To connect to MyMoney database you will need to get a special database driver, you can get it from MTH Website at mth_derby Please save this file to the CustomReports folder as well.

You also need to point iReport to the MyMoneys class files - the easiest way of doing so is to create a link - please open a console and type the following commands:

1) cd /Users/xxx/CustomReports/
2) ln -s /Applications/MyMoney.app/Contents/Java/ ./Java

Please change xxx above to the location of your CustomReports folder


At this point your CustomReports folder should look like the following:



To start using iReport with MyMoney you will need to setup the datasource in iReport first. Please start iReport and select preferences, then iReport then Classpath (2nd tab after the General). Please add mth_derby.jar to your classpath by clicking on add JAR then navigating to CustomReports folder and then selecting mth_derby.jar

Once mth_derby.jar is added please click on Add Jar again, navigate to the Java linked folder, select all (you can press Control-A or Command-A) and add everything to the classpath

You classpath screen should look like the following:



To setup new Datasource please click on "Report Datasources" button, it is usually located next to the "Empty Datasource/Sample Datasource" choice list.


When prompted please make the following choices:

DataSource Type: Database JDBC Connection

Name: MoneyDB

JDBC Driver: org.apache.derby.jdbc.EmbeddedDriver

JDBC URL: this should be location to your database, for example jdbc:derby:/Users/username/Desktop/Test/Test/moneyDB


Your Datasource should look like the following:



Press Test, leave User Name and Password blank, your connection should be successful.

If you can't connect to the database please see this list of common iReport problems and resolutions

How_to_create_a_custom_Tax_report_in_My_Money#Some_common_problems_that_you_may_encounter_while_connecting_to_database_from_iReport


Once the datasource is setup you can open categorized_p100.jrxml through File-Open menu in iReport, your screen should look like the following:

Changing reports

Lets try to change the report somewhat, for the purposes of this article lets assume that we want to:

  1. Sort Transactions by their check number first and,
  2. Categorize Transactions by their check number, i.e. transactions sharing the same check number should be grouped together


Resorting Report

To apply different sorting you will need to change the default SQL query a bit, please open SQL Query Editor in iReport, ckecl in Report Query, and locate "Order By Section".

Please add new sorting order by adding MMY_SPLIT.CHECKNUM to the list of the sorting conditions. This tells the SQL Processor to order the results first by the field CHECKNUM which contains check numbers, then by other conditions, such as categories, transaction dates, etc.



You can always test the editing by running reports in place -- if you switch into the "Preview" mode and your database connection is defined to open your Money file you will see the results right away



Adding a new Report Group

To categorize and summarize report on a new criteria you will need to create a new Report group, in this case we will be creating a group where all checks sharing the same number are grouped together and their combined amount is calculated and displayed on the report.


To get started please right click somewhere on the report and select "Add New Group" menu



Please specify that the new group needs to operate on CHECKNUM field and give it a name, for example CHECK. You probably will want to have group headers and footers if you want to show relevant group information, so you can leave rest of the settings as it is.



Once the group is created you will need to manually create a new Variable to hold the results of calculations: Please expand Variables set in the Reports Inspector, create a new Variable and in the Properties specify that its type is a Group and you want to summarize the amounts. Please also specify what to summarize, in this case it would be AMOUNT, i.e. for each element in the group your new variable will be incremented by transactions AMOUNT.


Lastly, please create (or copy through Command-C/Command-V) a text box on the report and place it inside the CHECK Group Footer area. This will be printed once per new Group. Please specify that the text in the textbox refers to your new variable ${CheckAmount}



At this point your new report should be operational, if you click on preview you should see that the Transactions with the same check number are grouped together and their combined amounts are printed underneath.



At this point the two objectives are complete, to streamline the report a bit you can remove categorization by Transaction Categories if it is not needed, change the report Headers, Footers, Fonts, etc.


Once you are done with the report please change the name so it is meaningful for you, for example categorized_check_p100.jrxml

You can copy the new report back into MyMoney system directory and you will see it next time you restart MyMoney.

Please note that if you re-install MyMoney you will lose all custom reports installed in MyMoneys system areas, so please keep a backup.


Persisting User Defined Report

MyMoney has a special location for user-defined reports. If you place your report there it will not disappear if you reinstall or upgrade MyMoney.

The location of this folder changes depending on the system and operating permissions. The easiest way to locate it is

to start MyMoney, use View-Show console menu and type the following command in the console -
print(SwingMoneyView.singleInstance.environment.getUserApplicationHome());
Please note the output, this is where your user data is written to, for example it could be
/Users/xxx/Library/Containers/com.mth.money/Data/Library/.mymoney

Once you located this folder you need to create a report folder within it, to do so please open a Finder window and use Go-Go to folder to navigate to the user data (/Users/xxx/Library/Containers/com.mth.money/Data/Library/.mymoney)

While in user data folder please change to system, if you don't have a 'reports' folder please create it, and then please create 'user'folder so your structure looks like /Users/xxx/Library/Containers/com.mth.money/Data/Library/.mymoney/system/reports/user

Please copy your reports into this system/reports/user folder

Please start MyMoney.app, switch to Reports folder - if you did everything correctly you will see User Reports section that will contain your newly copied report. If you update MyMoney in the future your User defined report will survive

Personal tools