There are payments with the same number for the same provider, e.g. two payments with
Document # 000588, but with the different ids.
The issue is caused by the bug with id #PBA-69470 ("Duplicate payment numbers"). Enumerator for payments has been reset to after reaching its limit.
Change the enumerator for payments:
Home> System> Settings> More Finance Settings> Enumerator Classes > PAYMENT Payment Enum
for example it is set to
000590, change it by adding additional
0 to the beginning -