This error is normally caused by an incorrect setting for AP/PR Last Reference Number for the payment method’s cash account.
To fix the issue:
Open the payment where you are getting the error and take note of the Payment Method and the Cash account used.
Navigate to the Payment Methods screen and Open the payment method that's linked to the payment you can't release
Find the line that corresponds to the cash account used on the payment.
On this line, check the AP Suggest next Number box and correct the next number that's shown.
If you’re not sure what the next number should be then this can be found on the number sequence screen as shown below