2

We moved from a different shop sytem to Magento 2.3 and customers already made some orders (Yay!). Due to some regulations all invoice numbers must be continuous.

How can I change the number of an already existing invoice?

Currently the latest invoice in Magento has the number "000000012" and I'd like to change it to "000004108" (for example) since the latest invoice was "000004107" in the old system.

I already found out about the table sequence_invoice_1 which I can modify to set the correct value for the next orders. Modifying existing values in this table did not affect exiting invoices. I suspect there must be some modifications done in the tables sales_invoice or sales_invoice_grid.

Any help is appreciated!

1

Yes you have to update the rows in sales_invoice and corresponding in sales_invoice_grid and change the increment_id. With that changes you're done.

1
  • Here is what I did: In the table sequence_invoice_1 I changed the value from 12 to 4107 and set the table's AUTO_INCREMENT to 4018 so the next invoice gets the correct number. In the tables sales_invoice and sales_invoice_grid I changed the values of the column increment_id from 000000012 to 000004107. Everything works! – EightBitBoy Feb 24 '19 at 19:44
0

This can be done in two scenarios.

1) Multi-store environment.

if you got a multi-store setup with your Magento 2 then you have to check for which store you would like to increase an id.

Don't make any changes via the update but all you need to do is via alter database command, so you have to alter the auto_increment id.

For order Id update

ALTER TABLE sequence_order_1 AUTO_INCREMENT = 100;

Here sequence_order_1 is the table and it's going to save all order id sequence for the store id 1. you may have multiple stores so you have to figure that out and based on that you can make amends here. The alter table command let you update the auto-increment field value for this sequence table so next order it will start with 100,

For invoice Id update

ALTER TABLE sequence_invoice_1 AUTO_INCREMENT = 100;

Here sequence_invoice_1 is the table and it's going to save all invoice id sequence for the store id 1. you may have multiple stores so you have to figure that out and based on that you can make amends here. The alter table command let you update the auto-increment field value for this sequence table so next invoice it will start with 100,

2) stand-alone environment.

The majority of the shop is a stand-alone ( default store ) setup with Magento. you can be logged into the database and check the default store id for sequence_order_... and sequence_invoice_...

Here ... means your store id.

After the above findings, you have to run the following command based on your requirements.

ALTER TABLE sequence_order_... AUTO_INCREMENT = 100;
ALTER TABLE sequence_invoice_... AUTO_INCREMENT = 100;

Don't forget to ... with your store id and you don't need to change any other tables or anything at all.

I hope this would help you with your task.

Regards,Sam

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.