Are you saying you want to be able to identify any project with 1 (or more) overdue invoices?
What are you adding up in the script? Values from all the invoices from the project, or just the overdue ones? Do you want to lose the detail when aggregating in the script, or do you want to keep the detail as well? Have you got massive amounts of data, so you have to aggregate?
If you put some sample lines of data and what you would want shown I might be able to share some other ideas.