I had similar problems, but on a much smaller scale. I thought I had a good relationship with one client and that invoices were being paid on time, but then I found that around £10k had been overlooked by AP over the course of a few years.
After that I phoned after every invoice - which was a pain in the ass for me and for AP, but the money (mostly) arrived on time.
It's really, really easy to miss how important admin and cashflow are. They're boring AF, but also too important to ignore.
Even worse is the realisation that sometimes you are going to be paid late, sometimes you are going to be offered partial payment, and sometimes you may never be paid at all - and these are all absolutely normal in business and you should expect them and have contingencies for them.
As a rule, any freelance work where you rely on timely payment from a single client to cover your outgoings is incredibly risky and dangerous and can easily become very stressful - because you are literally flirting with financial death.