首页 文章

Acumatica使用.net API创建销售订单

提问于
浏览
1

我正在使用基于Acumaticas合约的API,我需要创建一个新的销售订单 . 我正在使用C#并导入了AcumaticaAPI服务引用 . 到目前为止,我知道如何通过API创建销售订单,也无法在developer guide中找到如何执行此操作 . 这是我获取销售订单列表的代码:

public HttpResponseMessage AddSalesOrder(int id)
{

    var binding = new System.ServiceModel.BasicHttpBinding()
    {
        AllowCookies = true,
        MaxReceivedMessageSize = 655360000,
        MaxBufferSize = 655360000
    };

    var address = new System.ServiceModel.EndpointAddress("http://acumaticasandbox.mydomain.com/TestCompany/entity/Default/5.30.001");



    using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
    {
        client.Login("myuser", "mypass", "Test Company", null, null);

        Entity[] items = client.GetList(new SalesOrder(), false);


        client.Logout();

        return Request.CreateResponse(HttpStatusCode.OK, items);
    }
}
  • 如何修改此代码以创建新的销售订单?

  • 还有,有办法通过一系列销售订单对象或通过API导入文件(csv)来创建一批新的销售订单吗?

1 回答

  • 2

    您首先必须创建要在系统中插入的销售订单对象 .

    SalesOrder so = new SalesOrder
    {
        OrderType = new StringValue { Value = "SO" },
        CustomerID = new StringValue { Value = "ABARTENDE" },
        Details = new SalesOrderDetail[]
        {
            new SalesOrderDetail
            {
                InventoryID = new StringValue {Value = "AACOMPUT01" },
                Quantity = new DecimalValue {Value = 2m }
            },
            new SalesOrderDetail
            {
                InventoryID = new StringValue {Value = "AALEGO500" },
                Quantity = new DecimalValue {Value = 4m }
            }
        }
    };
    

    这些库存值来自演示数据 .

    然后,您必须使用Put调用在系统中插入新的销售订单 .

    SalesOrder result = (SalesOrder)client.Put(so);
    

    当然这是一个非常基本的销售订单 . 如果查看“销售订单” endpoints 定义中的所有字段,则这些字段都可以添加到正在创建的对象中,并且将同时插入 .

    如果您可以访问Acumatica大学,那么与基于 Contract 的API相关的课程就是I210 . http://acumaticaopenuniversity.com/courses/i210-contract-based-web-services/

相关问题