Bas, thanks for the reply.
First I add after line 67. When generating the bill appeared “Internal error”. I tried after line 77, but the situation was the same. In both cases, the invoice number was increased.
I am doing something wrong? After what line to copy instruction?