Acumatica在创建销售订单时更改装运条款

Acumatica在创建销售订单时更改装运条款,acumatica,Acumatica,我正在使用Acumatica基于合同的API从ASP.net应用程序创建销售订单。创建销售订单时,我需要更新“发货设置”选项卡下的“发货条款”字段(见下文),但我找不到通过基于合同的API提供的ASP.net对象上使用的属性。我将如何做到这一点 以下是如何创建销售订单的当前代码: using (DefaultSoapClient client = new DefaultSoapClient(binding, address)) { //Sales order data stri

我正在使用Acumatica基于合同的API从ASP.net应用程序创建销售订单。创建销售订单时,我需要更新“发货设置”选项卡下的“发货条款”字段(见下文),但我找不到通过基于合同的API提供的ASP.net对象上使用的属性。我将如何做到这一点

以下是如何创建销售订单的当前代码:

using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
    //Sales order data
    string customerID = "CUST1234;
    string orderDescription = "Automated Order";
    string customerOrder = "TEST";

    var orderDetails = new List<SalesOrderDetail>();

    foreach(var lineItem in order.line_items)
    {
        orderDetails.Add(new SalesOrderDetail {
            InventoryID = new StringValue { Value = lineItem.sku },
            Quantity = new DecimalValue { Value = lineItem.quantity },
            UnitPrice = new DecimalValue { Value = Decimal.Parse(lineItem.price) }, //TODO this should only be done for MHR owned sites
            UOM = new StringValue { Value = "EACH" },

        });
    }


    //Specify the values of a new sales order
    SalesOrder orderToBeCreated = new SalesOrder
    {
        OrderType = new StringValue { Value = "SO" },
        CustomerID = new StringValue { Value = customerID },
        Description = new StringValue { Value = orderDescription },
        CustomerOrder = new StringValue { Value = customerOrder },
        ExternalReference = new StringValue { Value = order.order_number.ToString() },
        Details = orderDetails.ToArray<SalesOrderDetail>(),
        ShippingAddressOverride = new BooleanValue { Value = true },
        ShippingContactOverride = new BooleanValue { Value = true },
        ShippingContact = new Contact()
        {
            DisplayName = new StringValue { Value = order.shipping_address.first_name + " " + order.shipping_address.last_name },
            FirstName = new StringValue { Value = order.shipping_address.first_name },
            LastName = new StringValue { Value = order.shipping_address.last_name },
            Address = new Address()
            {
                AddressLine1 = new StringValue { Value = order.shipping_address.address_1 },
                AddressLine2 = new StringValue { Value = order.shipping_address.address_2 },
                City = new StringValue { Value = order.shipping_address.city },
                State = new StringValue { Value = order.shipping_address.state },
                Country = new StringValue { Value = order.shipping_address.country },
                PostalCode = new StringValue { Value = order.shipping_address.postcode }
            }
        },

    };

    client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);

    //Create a sales order with the specified values
    try
    {
        SalesOrder newOrder = (SalesOrder)await client.PutAsync(orderToBeCreated);

        client.Logout();

        return newOrder;
    }
    catch (Exception e)
    {
        //order addition to Acumatica failed, update the order status in Woo Commerce
        client.Logout();
        Console.WriteLine("Acumatica could not add specified entity: " + e);
        return null;
    }

}
使用(DefaultSoapClient=new DefaultSoapClient(绑定,地址))
{
//销售订单数据
字符串customerID=“CUST1234;
string orderDescription=“自动订单”;
字符串customerOrder=“TEST”;
var orderDetails=新列表();
foreach(订单中的var行项目。行项目)
{
添加(新的SalesOrderDetail){
InventoryID=new StringValue{Value=lineItem.sku},
数量=新的小数值{Value=lineItem.Quantity},
UnitPrice=new DecimalValue{Value=Decimal.Parse(lineItem.price)},//TODO只应为MHR拥有的站点执行此操作
UOM=新字符串值{Value=“EACH”},
});
}
//指定新销售订单的值
SalesOrder orderToBeCreated=新的SalesOrder
{
OrderType=new StringValue{Value=“SO”},
CustomerID=new StringValue{Value=CustomerID},
Description=newstringvalue{Value=orderDescription},
CustomerOrder=new StringValue{Value=CustomerOrder},
ExternalReference=new StringValue{Value=order.order\u number.ToString()},
Details=orderDetails.ToArray(),
ShippingAddressOverride=新布尔值{Value=true},
ShippingContactOverride=新布尔值{Value=true},
ShippingContact=新联系人()
{
DisplayName=new StringValue{Value=order.shipping\u address.first\u name+“”+order.shipping\u address.last\u name},
FirstName=new StringValue{Value=order.shipping\u address.first\u name},
LastName=new StringValue{Value=order.shipping\u address.last\u name},
地址=新地址()
{
AddressLine1=new StringValue{Value=order.shipping\u address.address\u 1},
AddressLine2=new StringValue{Value=order.shipping_address.address_2},
城市=新StringValue{Value=order.shipping_address.City},
State=newstringvalue{Value=order.shipping_address.State},
Country=new StringValue{Value=order.shipping\u address.Country},
PostalCode=new StringValue{Value=order.shipping\u address.postcode}
}
},
};
client.Login(\u acumaticaUid,\u acumaticaPwd,\u acumaticaCompany,null,null);
//使用指定的值创建销售订单
尝试
{
SalesOrder newOrder=(SalesOrder)wait client.PutAsync(orderToBeCreated);
client.Logout();
返回新订单;
}
捕获(例外e)
{
//向Acumatica添加订单失败,请在Woo Commerce中更新订单状态
client.Logout();
Console.WriteLine(“Acumatica无法添加指定实体:”+e);
返回null;
}
}
更新: 根据PatrickChen的评论,我在Acumatica“SalesOrderCustom”中创建了一个新的web服务端点,在这里我使用了所有默认字段,然后将“ShippingTerms”添加到列表中。然后我将该web服务导入到我的.net项目中(由于问题而有些头疼)并且能够使用该服务获取我想要向其中添加装运条款的销售订单,并尝试对其进行更新。代码执行正常,但在PUT操作完成后,该对象在Acumatica中未更新,并且ShippingTerms属性返回为NULL。我做错了什么?下面的代码:

public async Task<SalesOrderCustom> UpdateShippingTerms(string customerOrder, string originStore, string shippingSpeed)
{
    var binding = CreateNewBinding(true, 655360000, 655360000);

    var address = new EndpointAddress(ConfigurationManager.AppSettings["AcumaticaCustomUrl"]);

    var soToBeFound = new SalesOrderCustom()
    {
        OrderType = new StringSearch { Value = "SO" },
        CustomerOrder = new StringSearch { Value = customerOrder }
    };

    using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
    {
        client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);

        try
        {
            var soToBeUpdated = (SalesOrderCustom) await client.GetAsync(soToBeFound);

            soToBeUpdated.ShippingTerms = new StringValue { Value = "USPS 1 CLS" };

            var updatedOrder = (SalesOrderCustom)await client.PutAsync(soToBeUpdated);
            //ShippingTerms is still NULL on returned object even after updating the object!!! WHY???

            client.Logout();
            return updatedOrder;
        }
        catch (Exception e)
        {
            client.Logout();
            Console.WriteLine("Acumatica could not find specified entity: " + e);
            return null;
        }
    }
}
public async Task UpdateShippingTerms(字符串customerOrder、字符串originStore、字符串shippingSpeed)
{
var binding=CreateNewBinding(true,655360000,655360000);
var address=新的端点地址(ConfigurationManager.AppSettings[“AcumaticaCustomUrl”]);
var soToBeFound=new SalesOrderCustom()
{
OrderType=new StringSearch{Value=“SO”},
CustomerOrder=new StringSearch{Value=CustomerOrder}
};
使用(DefaultSoapClient=new DefaultSoapClient(绑定,地址))
{
client.Login(\u acumaticaUid,\u acumaticaPwd,\u acumaticaCompany,null,null);
尝试
{
var soToBeUpdated=(SalesOrderCustom)wait client.GetAsync(soToBeFound);
soToBeUpdated.ShippingTerms=新的StringValue{Value=“USPS 1 CLS”};
var updateOrder=(SalesOrderCustom)wait client.PutAsync(soToBeUpdated);
//即使在更新对象之后,返回的对象上的ShippingTerms仍然为空!!!为什么???
client.Logout();
返回更新的订单;
}
捕获(例外e)
{
client.Logout();
Console.WriteLine(“Acumatica找不到指定的实体:”+e);
返回null;
}
}
}

我在创建新的6.0端点时可以添加装运条款。Acumatica附带的默认端点不可扩展。

我在创建新的6.0端点时可以添加装运条款。Acumatica附带的默认端点不可扩展。

启动Acumatica 6,可以更新任何字段,未包含在默认端点中。此功能仅适用于实施第二版系统合同的端点:

下面的示例显示了如何通过使用
自定义字段
集合,为具有基于合同的默认端点的销售订单更改装运条款

using (var client = new DefaultSoapClient())
{
    client.Login("admin", "123", null, null, null);
    try
    {
        var order = new SalesOrder()
        {
            OrderType = new StringSearch { Value = "SO" },
            OrderNbr = new StringSearch { Value = "SO003729" }
        };
        order = client.Get(order) as SalesOrder;
        order.CustomFields = new CustomField[]
        {
            new CustomStringField
            {
                fieldName = "ShipTermsID",
                viewName = "CurrentDocument",
                Value = new StringValue { Value = "FLATRATE2" }
            }
        };
        client.Put(order);
    }
    finally
    {
        client.Logout();
    }
}
更新销售订单发货时,我方也未发现任何问题
using (var client = new DefaultSoapClient())
{
    client.Login("admin", "123", null, null, null);
    try
    {
        var order = new SalesOrder()
        {
            OrderType = new StringSearch { Value = "SO" },
            OrderNbr = new StringSearch { Value = "SO003729" }
        };
        order = client.Get(order) as SalesOrder;
        order.ShippingTerms = new StringValue { Value = "FLATRATE1" };
        client.Put(order);
    }
    finally
    {
        client.Logout();
    }
}