It seems poor practice to be automatically altering previously entered transactions. In addition to @Joe91’s warning about doubling the tax accounting, you would also have trouble with line items.
I suspect you imagine a situation where you have paid for a single line item. Perhaps you have paid a utility bill. Now you want to be able to copy the payment to a purchase invoice for the same supplier. You would want the purchase invoice to post the line item to a Utilities expense account and change the payment to Accounts payable > Utility Company > PI#. That might work in your scenario.
But the program has to account for other situations. For illustration, suppose someone has a payment with three line items:
- Inventory item A posted to one asset control account. These goods were taxed.
- Inventory item B posted to a second asset control account. These goods were exempt from tax.
- Shipping charges posted to an expense account.
Now complicate the situation by adding the fact that the quarterly tax filing has already been made before the purchase invoice is created, and local tax regulations separate cash and credit purchases. What do you do?
Take things one step further. What happens to the shipping charges. Do you now convert them to freight-in costs so they are distributed and capitalized with the inventory in the asset control accounts? (That could only happen on purchase invoices, not payments.) And how do you handle the fact that someone might try to make this conversion after an accounting period is closed, financial statements have been prepared, and taxes have been filed?
My point is that what seems straightforward on first thinking can become horribly complex and confusing when rolled out into the world. Could all this be handled? Yes, but is it worth it, considering what would be needed to prevent unforeseen consequences? Probably not.