Modern cars are hugely complicated things, an example , I've recently bought a 15 plate cat C Mercedes B class , it's done 3000 miles and fixed and running it cost me 50% of the new price.
However , mine was mechanical , it was involved in a front end shunt at 3 months old , repaired using all new Mercedes parts by a MB approved body shop, then for whatever reason in their care the engine seized so the insurance company declared it a CAT C because a new engine is 10k
I had a new engine fitted but it needed to go to Mercedes to be coded , LED lights wouldn't work because they have beam assist and the computer didn't know where they were pointing, 7 speed auto but it wouldn't select a gear because the engine had been replaced and the computer didn't know where the clutch was
£500 later Mercedes got all the sensors talking to the many computers and its all working.
I can't imagine how difficult it would have been using secondhand parts of unknown origin or condition , I'd buy a mechanical CAT car again but regardless of the story the bodyshop gives you there will be something under that battered bodywork they can't see until you've bought it and they're sucking air through their teeth