How to change filename in Payroll Entry

I’m having problems while creating Payroll Entries. I think I can see where the problem is being generated. This is a core doctype and I couldn’t find the way it creates the name (naming_series, format, etc, are missing). By comparing two different employees I found, in the employee which I have trouble with, that when an entry was cancelled the naming sequence is different from the one whose entries also were cancelled before.
The employee with problematic sequence:

  • 00009
  • 00010 (cancelled)
  • 00010-1 (strang behaviour)

Correct sequence behaviour

  • 00009
  • 00010 (cancelled)
  • 00011 (cancelled)
  • 00012 (cancelled)
  • 00013

It seems that now it tries to create a new 00010 (filename?) but having a 00010-1 breaks something.