It is always to better to pass Credit note for wrong Invoice rather than changing it from back end.
It make your system vulnerable and inconsistent as one transaction entry is affecting lot of tables.
The answer is still the same. I suppose you could automate the process of creating and posting Credit Memos and Sales Orders, but you’ll never get it right if you try by just changing the values in the posted documents then try chasing the all of the related ledger entries.
Even if it seems daunting, doing it the right way will serve you better in the long run.