如何创建部分发票? [英] How to create partial invoice?

查看:82
本文介绍了如何创建部分发票?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从一个特定的订单中,我想为该订单中的某些选定项目创建发票.

From a specific order I want to create an invoice for some selected items from that order.

我已经以编程方式成功创建了整个订单的发票,但是我想创建该订单的部分发票.

I have successfully created an invoice for the whole order programmatically, but I want to create a partial invoice of that order.

推荐答案

最后我明白了.
必须挖magento才能得到这个.

Atlast I got it .
Had to dig magento to get this .

$orderid // order id
$order = Mage::getModel('sales/order')->load($orderid);

or for order increment id 
$orderincrmentid // order increment id

$order = Mage::getModel('sales/order')->loadByIncrementId($orderincrmentid);


if($order->canInvoice()) {          
    $invoiceId = Mage::getModel('sales/order_invoice_api')
            ->create($order->getIncrementId(), $itemsarray ,'your_comment' ,1,1);
}
echo $invoiceId; // Gives increment Invoice id

@parameters用于上述创建功能:

第一个参数:订单增量编号

第二个参数:数组

// array format . [Main point]

   foreach($order->getAllItems() as $item) {
$item_id = $item->getItemId(); //order_item_id
$qty = $item->getQtyOrdered();   //qty ordered for that item
}

array('56'=>'3','57'=>'1','58'=>'0');

array([order_item_id] => [qty]); // general array format

因此,您将在此处添加订单项ID作为键,并添加其数量作为其值.
如果不想创建一个特定的发票编号,则只需将其数量的值传递为0 // zero .

So here you will add order item id as key and its qty as its value .
If one do not want to create invoice id a particular item then simply pass value of its quantity as 0 // zero .

第3个参数:注释

第4个参数:发送邮件----> 1 不发送邮件----> 0

4th parameter : to send mail ----> 1 not send mail ----> 0

第5个参数:在邮件中包含注释----> 1 在邮件中不包含评论----> 0

5th parameter : include comment in mail ----> 1 not include comment in mail ----> 0

它返回发票增量id.

希望它对某人有帮助.

这篇关于如何创建部分发票?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆