Jump to content

change the invoice number (how to decrease it?)


Recommended Posts

Hi, by mistake I activated the invoice for some order that didn't need it.

So the invoice number increased when it shouldn't have.

Now I've just had an order where the invoice is actually needed. I changed the number via PHPMyadmin, but for the next invoices I don't know what to do. In the BO Invoices page I can only increase the invoice starting number, but it doesn't let me decrease it. What can I do?

Thank you in advance!


Link to comment
Share on other sites

Hi Vekia, thank you for your quick reply.

I noticed that the number in the ps_order_invoice and the invoice_number in the ps_orders table don't have the AUTO_INCREMENT option set, so I suppose it's Prestashop and not the db which should be edited.



Link to comment
Share on other sites

I noticed that the Order Class (/classes/order/Order.php) has a function called getLastInvoiceNumber() that selects the MAX number in the numbers row in ps_order_invoice table. So I have to manually edit the numbers in the orders which didn't need the invoice.

Thank you anyway.

public static function getLastInvoiceNumber()
		return Db::getInstance()->getValue('
			SELECT MAX(`number`)
			FROM `'._DB_PREFIX_.'order_invoice`

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...