Invoice help / suggestions

I am just after people suggestion / tips / experiance for this one, I ahve come up with a high level issue, i not sure of a solution to yet.

I have 2 custom modules, Sites and Plots. (building company)

A site can have many plots

Plots will have their status changed to complete once they are finished. Then once a month we need to generate a invoice for sites that have had plots finished that month. All plots invoiced for the same site needs to be on the same invoice. Then the plot status will need to be changed to invoiced.

It may take serval months to invoice all plots for a site. At any one time there is multiple sites and lots of plots, so this can’t be a manual process. Ideally this process needs to be kicked of by a user each month.

The main issue I think is trying to get all the plots invoiced on the same invoice for each site. If this was not a requirement i was just going to use a pdf tempate on plots and have the user do a batch action once a month.

Any ideas how this can be achieved?

I was thinking that perhaps a nice way to approach this would be to have a hook that tracks when plots are added or modified.

This hook would intelligently update line items for a monthly invoice (creating it, if it doesn’t exist yet for that month). Basically the items would be added one by one to the site’s current month invoice, as business rolls along, and then when the time comes to send the invoice, at the end of the month, it already contains all the necessary line items.

This seems straight-forward to implement, I believe.