I have an application built in Drupal 7 that records properties as nodes and relates property nodes to charge nodes and payment nodes.
I would like to add the ability to view a report by selecting a property and specifying two dates, a start date and an end date for the report, that shows a total of payments, a total of charges and then a balance total for a particular property.
However, the charges content type is only used to record additional charges to a property. There is a monthly service charge which is stored as an amount in a field of the property node. So when generating the report, I simply add one service charge payment for each month the report spans.
A summary of the report:
Select a property and give a date range. Produce a list of charges by :
- Adding one service charge for each month between the two dates. (Note: The service charge amount is given in a field of the property node)
- Adding amount from all charge nodes related to this property.
- Give a total field for all the charges.
- Show all payments from payment nodes related to this property.
- Total the payments.
- Give a balance total(charge total - payment total)
What I can't figure out is if views can build the report I need.
Can this be done by adding calculated fields to views, in particular the service charge payments, or do I have to do this in a template file (views-view--foobar--page.tpl.php for example)?
I know how to get all payments and charges related to a property into a view, but I am not sure where to go from there. Maybe this comes down to personal preference, but this is my first venture into views and I would appreciate some advice on where I should be concentrating my efforts!