2

I want to re-numbering of invoices. The renumbering should be composed as follow.

I would like this format for invoice ID's: INV-10001-2014

INV-00001-13; INV-00002-13; O-00003-13; ['INV' for invoice, 5 places for the number; “-“ ; current year. Next year this numbering should finish in 14 (from 2014).

Shiv Kumar Sah
  • 1,129
  • 1
  • 13
  • 17

3 Answers3

1

You can customize order/invoice/creditmemo/shipment number (increment_id) by editing the following Class :

Mage_Eav_Model_Entity_Increment_Numeric

Especially, closely look at the code of the following methods:

getNextId() , getPrefix() , getPadLength() , format($id)

Now, you won't find the method definition for methods getPrefix() , getPadLength() because these are magic getter methods. You can define these methods according to your desire.

For an example:

public function getPrefix(){
     $prefix = $this->_getData('prefix');
     /* Do some customization */
    return $prefix;
} 
public function getPadLength()
{ 
     $padLength = $this->_getData('pad_length');

     /* Do some customization */

     return $padLength;
}

This way, you don't have to manually change anything in the database structures for this to achieve.

Hope this will help you.

asmmahmud
  • 4,844
  • 2
  • 40
  • 47
  • This will affect ALL the entities mentioned by you at the start of the answer ( order/invoice/creditmemo/shipment number ) To only updated the Invoice Number format one would have to follow another approach. – Dragos Sep 29 '14 at 14:38
0

you can use the Event sales_order_invoice_save_before to set the custom invoice number

In your observer method use

$invoice = $observer->getInvoice();

$newInvoiceId = 'Your new Invoice id'

$invoice->setIncrementId($newInvoiceId);
Amit Kumar
  • 1,774
  • 1
  • 16
  • 27