Asif,
If it is your first article then I must say -decently written article.
I have also dealt with such situations many times but what I noticed in your solution was that you did not handle the case if maximum possible Invoice Id (i.e. yy-99999) was already generated. However, you put enough attention not to let generate a duplicate.
Anyways, it was a good article and keep sharing.
[Aarez]