【问题标题】:Magento - custom invoice id formatMagento - 自定义发票 ID 格式
【发布时间】:2013-12-06 10:49:42
【问题描述】:

我想重新编号发票。重新编号的组成如下。

我想要发票 ID 的这种格式:INV-10001-2014

INV-00001-13; INV-00002-13; O-00003-13; ['INV' 为发票,编号为 5 位; “-”;今年。明年这个编号应该在 14 结束(从 2014 年开始)。

【问题讨论】:

    标签: php magento invoice


    【解决方案1】:

    您可以通过编辑以下 Class 来自定义订单/发票/creditmemo/shipment number (increment_id):

    Mage_Eav_Model_Entity_Increment_Numeric
    

    特别是仔细看下面方法的代码:

    getNextId() , getPrefix() , getPadLength() , 格式($id)

    现在,您将找不到方法 getPrefix() 和 getPadLength() 的方法定义,因为这些是神奇的 getter 方法。您可以根据需要定义这些方法。

    举个例子:

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

    这样,您无需手动更改数据库结构中的任何内容即可实现。

    希望这会对您有所帮助。

    【讨论】:

    • 这将影响您在答案开头提到的所有实体(订单/发票/creditmemo/发货编号)要仅更新发票编号格式,必须遵循另一种方法。跨度>
    【解决方案2】:

    您可以使用事件sales_order_invoice_save_before来设置自定义发票编号

    在你的观察者方法中使用

    $invoice = $observer->getInvoice();
    
    $newInvoiceId = 'Your new Invoice id'
    
    $invoice->setIncrementId($newInvoiceId);
    

    【讨论】:

      【解决方案3】:
      猜你喜欢
      • 2012-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-12
      • 2015-06-07
      • 1970-01-01
      • 2011-06-28
      • 1970-01-01
      相关资源
      最近更新 更多