Shiv Kumar Sah
Shiv Kumar Sah

Reputation: 1076

Magento - custom invoice id format

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).

Upvotes: 2

Views: 1336

Answers (3)

asmmahmud
asmmahmud

Reputation: 5044

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.

Upvotes: 1

Amit Kumar
Amit Kumar

Reputation: 1772

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);

Upvotes: 0

Related Questions