Magento API 的创建发票方法无法正常工作 [英] Create Invoice Method is not working properly of Magento API

查看:23
本文介绍了Magento API 的创建发票方法无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 XMLRPC 在 android 应用程序中使用 Magento API 创建销售订单发票.我正在使用方法sales_order_invoice.create"来创建发票.此方法在magento wiki 中提到的给定数量的响应.但是问题是 magento 商店中的发票数量未更新.另一件事是订单状态正在更改为正在处理,这是正确的,并且已创建发票的条目也存在于商店的发票列表中,但将支付金额显示为 $0.0 这是不正确的.

I am trying to create sales order Invoice using Magento API in android application using XMLRPC.I am using the method "sales_order_invoice.create" for creating invoice.This method is giving me Invoice Id in the response for given quantity as mention in magento wiki.But the problem is that the Invoice qty isn't updated on magento store.Other thing is Order status is changing to Processing which is correct and the entry of created invoice is also present in invoice list of store but It is displaying the paid amount as $0.0 which is not correct.

不知道在调用sales_order_invoice.create之前是否需要调用其他方法或者方法有问题??
下面是我调用方法的部分代码:

I don't know if I need to call another method before calling sales_order_invoice.create or is there any problem in the method??
Below is some part of my code for calling method:

import java.util.HashMap;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class MagentoStore extends Activity {

private XMLRPCClient client;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
            String sessionId = "";


client = new XMLRPCClient("http://www.mystore.com/index.php/api/xmlrpc");
        try {

            sessionId = (String)client.call("login", "tester", "tester");
            Log.d("MY_XMLRPC_SUCCESS_SESSION_ID", sessionId);
            }
         catch (XMLRPCException e) {

            Log.d("MY_XMLRPCException_MSG", e.getMessage());
        }

        Object salesorderInfo = null;
        Object[] methodParams = new Object[]{"100000028"};
        Object[] callParams = new Object[]{sessionId,"sales_order.info", methodParams};
        String salesorderinvoice= null;
        try {
             salesorderInfo = (Object)client.callEx("call",callParams);
             HashMap map = (HashMap)salesorderInfo;
             Object[]items=(Object[])map.get("items");
             for(Object item :items)
             {
                 HashMap itemlist=(HashMap)item;
                 String item_id=(String)itemlist.get("item_id");
                 int itemids=Integer.parseInt(item_id);
                 String base_price=(String)itemlist.get("base_price");
                 if(base_price.equals("0.0000"))
                 {
                  continue;  
                 }   
                 String name=(String)itemlist.get("name");
                 Double qty=1.0;
                 String qty_ordered =(String)itemlist.get("qty_ordered");
                 String qty_invoiced=(String)itemlist.get("qty_invoiced");
                 Object[] methodParams1 = new Object[]{"100000028",itemids,qty};
                 Object[] callParams1 = new Object[]{sessionId,"sales_order_invoice.create", methodParams1};
                 salesorderinvoice= (String)client.callEx("call",callParams1);

             } 
            } catch (Exception e) {
            Log.d("APP_INFO", "Exception: " + e.getMessage());
            }               
    }
}

有人有什么想法吗??提前致谢

Anyone have any Idea?? Thanks in advance

推荐答案

仅供参考

调用 API sales_order_invoice.create 时,必须分配数组指针名称.

when you call the API sales_order_invoice.create, you must assign the array pointer name.

String qty_ordered =(String)itemlist.get("qty_ordered");
                 String qty_invoiced=(String)itemlist.get("qty_invoiced");
                 Object[] methodParams1 = new Object[]{"100000028",itemids,qty};

尝试使用

methodParams1.toString();

必须与

array(
      'orderIncrementId' => '200000008', 
      array(
            'order_item_id' => '11', 
            'qty' => '1'
      )
);

因为这是将参数放入sales_order_invoice.create

$result = $client->call(
    $session,
    'sales_order_invoice.create',
    array('orderIncrementId' => '200000008', array('order_item_id' => '11', 'qty' => '1'))
);

这篇关于Magento API 的创建发票方法无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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