Hi, Daniel. A received payment that is associated with a bank deposit cannot be deleted directly, as doing so could cause discrepancies in your bank register. This is why you encounter the error shown in the example screenshot below.

To remove the payment, you’ll need to delete the bank deposit first. Open the associated bank deposit by clicking the hyperlinked date below the customer name.

On the Bank Deposit screen, click More > Delete > Delete transaction to remove the deposit. After deleting the deposit, you can then delete the received payment.
Once the payment is deleted, the invoice will reopen and be ready for the correct payment to be applied.
Let me know if you need anything else. We're here to help.