Invoice numbering - start from 1 in new group - error



Ive recently updated IP to v1.4.10 from v1.4.4.

2016 is over, I want to enter new year for books and all other stuff for my business.

In my country from 01.01. every new invoice created have to start from number 1; for e.q. last invoice # (number/id) in 2016. was 20/W/1 (/W/1 must be with invoice no. by the law…). and first in 2017. must be 1/W/1

Ive tried to created new invoice group with the same unique id and create new invoice in that group.
IP creates invoice and saves draft (that is ok) but when I try to change anything and click Save it trows me an error : “The Invoice # field must contain a unique value.

In db I can see that invoice in table, and when I change it thru phpmyadmin its ok, but if I try to change anything and save it i get the same problem again.

Ive tried same thing with v1.4.4. and 1.4.10

Is it a bug or am I doing something wrong?



InvoicePlane only checks if the invoice ID already exists. So I suppose that there already is an invoice with the exact same ID in the database.


Hi Kovah,

yes, there is an invoice with same ID in DB.

I think Ive found a “solution”:

in the v1.4.4 in file application/modules/invoices/models/mdl_invoices.php @ line 144
'rules' => 'required|is_unique[ip_invoices.invoice_number' . (($this->id) ? '.invoice_id.' . $this->id : '') . ']'
'rules' => 'required'

in the v1.4.10 same file @ line 145
'rules' => 'is_unique[ip_invoices.invoice_number' . (($this->id) ? '.invoice_id.' . $this->id : '') . ']'
'rules' => 'required'

now Im able to save invoice without an error.

Will this mess up something else or it can be like this?
I mean will forcing same invoice ID/name mess up something other in the system?



Using the same ID for two different invoices is not recommended as it may lead to further probkems within the app.


What kind of, if I may ask?

I was using v1.4.4 for one year, and then updated the IP.

Other solution is to backup it, all files and db, drop most of the tables (invoices tables, preserve clients, quotes, settings, users…) and then start all over again.
If some inspection comes, show them on local server past year, and on live server current year.

To be hones, I dont like second solution :slight_smile:


Edit: as I can see in db, unique ID in ip_invoices is not invoice_number column it is invoice_id


I honestly don’t know exactly but I could bet that somewhere invoices are queried by their number. (I meant the number, not the ID, sorry)

I would simply add the year to the invoice group identifier. Like 2017/1/W/1.


hmm, I will try with this. if I find some errors I will post them.

This will be excellent solution but law in Croatia its not allowing that kind of naming/numbering invoices.