Invoice and tickets

Hello,

I have a QuickBooks integration that syncs invoices to HubSpot. If an invoice remains unpaid for 30 days, a ticket is automatically created on day 31.

The challenge is that some companies bill separately by state but have one main contact person. When they make a payment, they settle multiple invoices together.

Since we need to open a ticket for every overdue invoice, I want to automatically close all related tickets for that company—except for the oldest one, which should stay open. How can I configure this?