As with so many things, whether COTS will do for you is an "it depends" kind of answer.
If the COTS has most of what you need at a reasonable cost and is reliable, then it may be the best solution. However, too much software out there has a bunch of "bloat" - features you don't need but are being charged for.
Far back in my past we were looking for a change management system that accommodated DB4. The two major packages that handled it ran around $2,500,000 and had tons of functionality for other languages that we just didn't need (our home-grown change management system already handled our other needs).
I was given an intern and three months, and we developed a module for our homegrown system that handled the DB4 just as well as those more expensive systems. Five years later the home-grown version was still working just fine with minimal maintenance.
TCO always needs to take maintenance costs into account. A lot of our software comes with yearly maintenance or licensing fees, or upgrade fees. Then, as mentioned, there is training or a learning curve. All of that needs to be taken into account - there is always a cost.
Sometimes COTS is better, sometimes build-your-own works out. I have to chuckle sometimes regarding the "open source is free!" argument. It's free like a puppy. 😛 You still have to buy the food dishes, leash, shots, de-worming, neutering, etc. Not to mention the food! And if you're smart, you'll do the training too.
For software, you really should do the TCO even if some of the costs are just estimates. It at least gives you a number you can compare with other options.
Here there be dragons...,