clio_Td Posted February 18, 2016 Share Posted February 18, 2016 Hello, I would like to know where is generated the invoice number ? It seems to use a max(invoice_number) + 1 to generate teh new one, but where in teh code ? And in which table first Orders or Order_Invoice ? Thank you for your help, Willy Link to comment Share on other sites More sharing options...
safa Posted February 18, 2016 Share Posted February 18, 2016 classes/order/order.php this function creating new invoice id public static function setLastInvoiceNumber($order_invoice_id, $id_shop) { if (!$order_invoice_id) { return false; } $number = Configuration::get('PS_INVOICE_START_NUMBER', null, null, $id_shop); // If invoice start number has been set, you clean the value of this configuration if ($number) { Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $id_shop); } $sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET number ='; if ($number) { $sql .= (int)$number; } else { $sql .= '(SELECT new_number FROM (SELECT (MAX(`number`) + 1) AS new_number FROM `'._DB_PREFIX_.'order_invoice`'.(Configuration::get('PS_INVOICE_RESET') ? ' WHERE DATE_FORMAT(`date_add`, "%Y") = '.(int)date('Y') : '').') AS result)'; } $sql .= ' WHERE `id_order_invoice` = '.(int)$order_invoice_id; return Db::getInstance()->execute($sql); } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now