title: Prestashop 1.6 Order Number sequence reset per time period
body: <h2>SYNOPSIS</h2>
  <p>I am running my eCommerce shop using Prestashop 1.6.  I have already reconfigured my Order Numbers to the format <code>SO/2018/000001</code> based on <code>ps_orders.ps_id_order</code> using <a href="https://stackoverflow.com/a/30053257/2464491">this answer</a> as a guide. Updating <code>override/classes/PaymentModule.php</code> with this block:</p>
  <pre><code>$oNum = str_pad($order-&gt;id, 6, '0', STR_PAD_LEFT);
  $oYear = substr(date(Y),0,4);
  $order-&gt;reference = &quot;SO/$oYear/$oNum&quot;;
  $order-&gt;update();
  </code></pre>
  <p>I then used the following query to update set determine the next <code>id_order</code>:</p>
  <pre><code>ALTER TABLE ps_orders AUTO_INCREMENT = 10
  </code></pre>
  <p>This made my <code>reference</code> longer than the defined field, so I also had to adjust the definition in <code>/override/class/Order.php</code>:</p>
  <pre><code>'reference' =&gt; array('type' =&gt; self::TYPE_STRING, 'size' =&gt; 14),
  </code></pre>
  <p>And in <code>/override/class/OrderPayment.php</code>:</p>
  <pre><code>'order_reference' =&gt; array('type' =&gt; self::TYPE_STRING, 'validate' =&gt; 'isAnything', 'size' =&gt; 14),
  </code></pre>
  <p>With all that done, my order numbers were formatted the way I wanted, but are not exactly as desired.</p>
  <h2>DESIRED RESULT</h2>
  <p>Rather than using the <code>ps_orders</code> table's key index field as the basis of my order numbers, I would like to use a separate sequence which resets each year.  Similar to how the <code>OrderInvoiceCore</code> class uses the <code>number</code> field to generate the actual invoice number based on the <code>Invoice Options</code> set in the back office.</p>
  <h2>PLEASE ADVISE</h2>
  <p>What is the best way to go about achieving this desired result?  I am thinking that adding a sequence to the <code>OrderCore</code> class, and using that to generate my order reference numbers in place of <code>ps_orders.id_order</code> would do the trick.  If that is the best solution in my case, how do I go about implementing such?</p>